akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    string s;  cin >> s;
    ll n = s.size();
    string a="";
    bool flag = 0;
    for(int i=0;i<(n-1)/2;i++){
        if(s.at(i) != s.at(((n-3)/2)-i)){
            flag = 1;
        }        
    }
    for(int i=(n+1)/2;i<n;i++){
        if(s.at(i) != s.at(n-1-(i-(n+1)/2))){
            flag = 1;
        }
    }
    for(int i=0;i<n;i++){
        if(s.at(i) != s.at(n-1-i)){
            flag = 1;
        }
    }
    if(flag){
        cout << "No" << endl;
    }else{
        cout << "Yes" <<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    int a,b,x;
    int z;
    scanf("%d %d %d",&x,&a,&b);
    z=a-b;
    if(z>=0) printf("delicious\n");
    else if(z<0 && abs(z)<=x) printf("safe\n");
    else printf("dangerous\n");
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

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

        int n = in.nextInt();

        int odd = 0;
        for(int i = 1; i <= n; i++){
            int x = in.nextInt();
            if(x % 2 == 1) odd++;
        }

        if(odd % 2 == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 30848
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

ll Pow(ll n, ll k) {
	ll ans = 1, a = n % MOD;
	while (k > 0) {
		if (k & 1) {
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		k >>= 1;
	}
	return ans;
}

ll Inverse(ll a) {
	return Pow(a, MOD - 2);
}

int main(void) {
	int i, j;
	ll num, a, b, ans = 0;
	cin >> num;
	vector<ll> d(60, 0);
	for (i = 0; i < num; i++) {
		cin >> a;
		for (j = 0; j < 60; j++) {
			if (a & (1ll << j))
				d[j]++;
		}
	}
	for (i = 0; i < 60; i++) {
		a = d[i] * (num - d[i]);
		a %= MOD;
		b = (1ll << i) % MOD;
		a *= b;
		a %= MOD;
		ans += a;
		ans %= MOD;
	}
	cout << ans << "\n";
	return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;




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

	ll a,b,c,x,ans=0;
	cin>>a>>b>>c>>x;
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
				if(i*500+j*100+k*50==x)
					ans++;
	cout<<ans<<"\n";




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll val[101];
ll wt[101];
ll dp[101][100001];


ll ks(ll n,ll w)
{
    ll result;
    
     if(dp[n][w]!=-1)
    {
        return dp[n][w];
    }
    
    if(n==0||w==0)
    {
        result=0;
    }
    
   
    else if(wt[n]>w)
    {
        result=ks(n-1,w);
        //dp[n][w]=result;
    }
    
    else
    {
        ll temp1=ks(n-1,w);
        ll temp2=val[n]+ks(n-1,w-wt[n]);
        result=max(temp1,temp2);
        
    }
    
    dp[n][w]=result;
    return result;
    
}



int main() 
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	memset(dp,-1,sizeof(dp));
//	val[0]=0;
//	wt[0]=0;
	
	ll n,w;
	cin>>n>>w;
	
	for(ll i=1;i<=n;i++)
	{
	    cin>>wt[i]>>val[i];
	}
	
	ll ans=ks(n,w);
	cout<<ans<<"\n";
	
}


Measured memory_bytes: 79232
#include <stdio.h>
 
long long num[100001];
 
int main(void){
	long long n, i, j, k, cnt = 0;
	long long a = 0, b = 0;
	
	scanf("%lld", &n);
	
	for (i = 0; i < n; i++){
		scanf("%lld", &num[i]);
		if (num[i] % 2 == 0) a++;
		else b++;
	}
	
	if (b%2) printf("NO\n");
	else printf("YES\n");
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S,T;
    cin >> S >> T;
    int N = S.size();
    int ans = 0;
    for(int i=0;i<N;i++) ans += (S[i]!=T[i]);
    cout << ans << "\n";
}

Measured memory_bytes: 3888
#include<bits/stdc++.h>
#pragma GCC optimize(3)
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;
struct _IO{_IO(){ios::sync_with_stdio(0);cin.tie(0);}}_io;
int parent[200005],value[200005];
int maxn=1;

int find(int a){
    if(parent[a]==a){
        return a;
    }
    else{
        return find(parent[a]);
    }
}

void freedom(int n){
    for(int i=1;i<=n;i++){
        parent[i]=i;
        value[i]=1;
    }
    return ;
}

void unionxy(int a,int b){
    if(find(a)==find(b)){
        return ;
    }
    else{
        value[find(a)]+=value[find(b)];
        parent[find(b)]=find(a);
        parent[b]=parent[find(b)];
        parent[a]=parent[find(a)];
    }
}

int main()
{
    int n,m;cin>>n>>m;
    freedom(n);
    for(int i=1;i<=m;i++){
        int a,b;
        cin>>a>>b;
        unionxy(a,b);
    }
    cout<<*max_element(value+1,value+n+1)<<endl;
}

Measured memory_bytes: 5132
import java.util.Scanner;

/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        int s = scanner.nextInt();
        int[] funcAns = new int[100010];
        boolean twice = false;
        funcAns[0] = s;
        int i = 1;
        while(!twice) {
            funcAns[i] = func(funcAns[i-1]);
            for(int j = i - 1; j >= 0; j--) {
                if(funcAns[i] == funcAns[j]) {
                    twice = true;
                }
            }
            i++;
        }
        System.out.println(i);
    }
    public static int func(int i) {
        if(i % 2 ==0) return i/2;
        return (i * 3) + 1;
    }
}

Measured memory_bytes: 23764
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val n = input.split(LINE_SEPARATOR).head.toInt
    val a = input.split(LINE_SEPARATOR).tail.head.split(" ").map(_.toLong)
    if (n == 0 && a(0) == 1) return 1.toString
    
    val asum = a.scanRight(0L)(_ + _)
    var parentNode = 1L
    val retList = 1L +: (1 to n).map{i =>
      val ret = max(min(parentNode * 2, asum(i)), 0)
      parentNode = ret - a(i)
      if (parentNode < 0) -1L else ret
    }
    if (retList.exists(_ < 0L) || a(0) != 0) "-1" else retList.sum.toString
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """3
      |0 1 1 2""".stripMargin -> """7
                                       |""".stripMargin,
    """4
      |0 0 1 0 2""".stripMargin -> """10
                                         |""".stripMargin,
    """2
      |0 3 1""".stripMargin -> """-1""",
    """1
      |1 1""".stripMargin -> """-1""",
    """0
      |1
      |""".stripMargin -> """1""",
    """10
      |0 0 1 1 2 3 5 8 13 21 34""".stripMargin -> """264"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 66372
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi 3.14159
int32_t main()
{
    IOS
   
	int n,k;
	cin>>n>>k;
	int a[n+2];
	for(int i=1;i<=n+1;i++)
		a[i]=i-1;
	int sum[n+2];
	sum[0]=0;
	for(int i=1;i<=n+1;i++)
	{
		sum[i]=sum[i-1]+a[i];
	}
	int ans=0;
	for(int i=k;i<=n+1;i++)
	{
		ans+=sum[n+1]-sum[n+1-i]-sum[i]+1;
		ans%=mod;
	}
	cout<<ans<<endl;
}       

Measured memory_bytes: 6728
#include <stdio.h>
#include <string.h>
int main()
{
    char s[100],c[100],l[100];
    int i,h,len,j,n,m,o,p,k;
    scanf("%s%s%s",s,c,l);
    len=strlen(s);
   for(i=0;i<len;i++){
        if(i==len-1) {
            p = s[i];
        }
    }

   len=strlen(c);
    for(j=0;j<len;j++) {
        if (j ==0) {
            n = c[j];
        }
    }
    len=strlen(c);
    for(j=0;j<len;j++) {
        if (j==len-1) {
            m = c[j];
        }}
    len=strlen(l);
        for(k=0;k<len;k++) {
            if (k ==0) {
                o=l[k];
            }}
        if(p==n&&m==o){
            printf("YES");
        } else{
            printf("NO");
        }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,b,p,q;
    cin>>n;
    std::deque<int> deq;
    std::deque<int> tmp;
    for (int i=1;i<=n;i++) {
        deq.emplace_back(i);
    }
    std::deque<int> tmp_p;
    for (int hoge=0;hoge<n;hoge++) {
        cin>>p;
        tmp_p.emplace_back(p);
    }
    std::deque<int> tmp_q;
    for (int piyo=0;piyo<n;piyo++) {
        cin>>q;
        tmp_q.emplace_back(q);
    }

    int count=0;
    do {
        for(int j=0;j<n;j++){
            tmp.emplace_back(deq[j]);
            if (j==n-1) {
                count++;
                int countp=0;
                for (int k=0;k<n;k++) {
                    if (tmp[k]!=tmp_p[k]) {
                        break;
                    } else {
                        countp++;
                    }
                }
                if (countp==n) {
                    a=count;
                }
                int countq=0;
                for (int l=0;l<n;l++) {
                    if (tmp[l]!=tmp_q[l]) {
                        break;
                    } else {
                        countq++;
                    }
                }
                if (countq==n) {
                    b=count;
                }
            }
        }
        tmp.clear();
    } while (next_permutation(deq.begin(),deq.end()));
    cout<<abs(a-b)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

  cout << (n*n*n) << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	private static final String UNKNOWN = "Unknown ";
	private static final String OPEND_BY = "Opened by ";
	private static final String CLOSED_BY = "Closed by ";

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		Set<String> set = new HashSet<String>();
		for (int i = 0; i < n; i++) {
			set.add(in.next());
		}
		int m = in.nextInt();
		boolean opend = false;
		for (int i = 0; i < m; i++) {
			String message;
			String id = in.next();
			if (set.contains(id)) {
				message = (opend) ? CLOSED_BY : OPEND_BY;
				opend = !opend;
			} else {
				message = UNKNOWN;
			}
			System.out.print(message);
			System.out.println(id);
		}
		in.close();
	}
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++) cin >> vec.at(i);

    int count=0;
    for(int i=0;i<=n-1;i++){
        if(i==n-1){count++; break;}
        if(vec.at(i)<vec.at(i+1)){
            while(i<n-1 && vec.at(i)<=vec.at(i+1)) i++;
            count++;
            //cout << vec.at(i) << endl;
        }else if(vec.at(i)>vec.at(i+1)){
            while(i<n-1 && vec.at(i)>=vec.at(i+1)) i++;
            count++;
            //cout << vec.at(i) << endl;
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

//I read this web page.
// http://krdlab.hatenablog.com/entry/20060322

int main(){

	double a,b,c,d,ans,r=6378.1;
	double value,x1,y1,z1,x2,y2,z2,distance;

	while(true){
		scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
		if(a == -1 && b == -1 && c == -1 && d == -1)break;

		x1 = r*cos(b*M_PI/180)*cos(a*M_PI/180);
		y1 = r*sin(b*M_PI/180)*cos(a*M_PI/180);
		z1 = r*sin(a*M_PI/180);

		x2 = r*cos(d*M_PI/180)*cos(c*M_PI/180);
		y2 = r*sin(d*M_PI/180)*cos(c*M_PI/180);
		z2 = r*sin(c*M_PI/180);

		distance = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));

		value = acos(1 - (distance*distance)/(2*r*r));

		ans = r*value;

		printf("%.0lf\n",round(ans));

	}

	return 0;
}

Measured memory_bytes: 3464
# C
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
N = getInt()
h = getIntList()
count = 0
def water(r,l):
    global count
    #print(r,l,h,count)#
    mn = min(h[r:l])
    count += mn
    for i in range(r,l):
        h[i] -= mn
    i = r
    #print(r,l,h,count)#
    while i<l:
        #print('i',i)#
        if h[i]>0:
            j = i+1
            #print('j',j)#
            while j<=l:
                #print(j)#
                if j>=l or h[j]==0:
                    water(i,j)
                    break
                j += 1
            i = j
        i += 1
water(0,N)
print(count)

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

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

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define FOR(i, a, b) for (ll i = (a), i < (N): i++)
#define all(A) A.begin(),A.end()

int main(){
    int N, M;
    cin >> N >> M;
    vector<pll> AB(N);
    rep(i, N) {
        cin >> AB[i].first >> AB[i].second; 
    }
    sort(all(AB));
    // sort(AB.begin(), AB.end());
    ll ans = 0;
    int i = 0;
    while (true) {
        if (AB[i].second >= M) {
            ans += M * AB[i].first;
            cout << ans << endl;
            return 0;
        }
        else {
            M -= AB[i].second;
            ans += AB[i].first * AB[i].second;
            i++;
        }

    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int t;
int a[252521];

int main(){
  scanf("%d%d",&n,&t);
  REP(i,n)scanf("%d",a+i);
  sort(a,a+n);
  int ans = 0;
  int bef = -2e9;
  REP(i,n){
    int x = a[i];
    if(bef+t < x){
      ans += t;
    }else{
      ans += x-bef;
    }
    bef = x;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int p;
    int q;
}data;

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}

int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}
//構造体の.pを降順
int comp( const void *c1, const void *c2 )
{ data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.p;   /* b を基準とする */
  int tmp2 = test2.p;
    return tmp2 - tmp1;}




int main(){
    int X;
    scanf("%d",&X);
    int min=1000;
    int temp=0;
    for(int i=sqrt(X);i>=1;i--){
        for(int j=6;j>1;j--){
            if(X>=(int)pow(i,j) && (X-(int)pow(i,j))<min){
                min=X-(int)pow(i,j);
                temp=(int)pow(i,j);
            }
        }
    }
    printf("%d",temp);
}



Measured memory_bytes: 2556
#include <bits/stdc++.h>
#include <chrono>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define display(v) for (auto x : v) cerr << x << ", "
#define dbg(x) cerr << (#x) << " = " << (x) << "\n"
#define dbgp(x) cerr << (#x) << " = {" << (x.first) << ", " << (x.second) << "}\n";
#define print(x) cerr << (#x) << " = [ ";display(x); cerr << "]\n"
#define pb push_back
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;


int main()
{
	fastio;

	ll n;
	cin >> n;
	map <pair<ll, ll>, ll> mp;
	pair <ll, ll> p[n];
	for (int i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;
		p[i] = {x, y};
	}
	sort(p, p + n);
	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			ll x = p[j].first - p[i].first, y = p[j].second - p[i].second;
			mp[{x, y}]++;
		}
	}
	ll ans = 0;
	for (auto x : mp)
	{
		ans = max(ans, x.second);
	}
	cout << n - ans;
}


Measured memory_bytes: 384
while True:
    n,x = [int(x) for x in input().split()]
    if (n,x)==(0,0): break
    cnt=0
    if 3*(n-1) >= x:     # If n-2 + n-1 + n < x, there is no combination
        a_max = x//3 - 1 # a_max + a_max+1 + a_max+2 = x
        if 2*n-1 < x: 
            a_min = x - (2*n-1) # set minimum value of a
        else:
            a_min = 1
        for a in range(a_min,a_max+1):
            b_max = (x-a-1)//2 # b_max + b_max+1 <= x-a
            b_min = (x-a) - n  # set minimum value of b
            b_min = b_min if b_min > a+1 else a+1
            cnt += b_max - b_min + 1
    print(cnt)

Measured memory_bytes: 7696
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	string s;
	cin >> s;
	set<char>st;
	for (auto i : s)st.insert(i);
	if (st.size() == 1) {
		vector<long long int>dp(N + 1);
		dp[0] = 1;
		for (int i = 1; i <= N; i++) {
			dp[i] = dp[i - 1];
			if (i > 1)dp[i] += dp[i - 2];
			dp[i] %= MOD;
		}
		long long int ans = dp.back();
		dp[0] = 1;
		dp[1] = 0;
		for (int i = 2; i <= N; i++) {
			dp[i] = dp[i - 1] + dp[i - 2];
			dp[i] %= MOD;
		}
		ans += dp.back();
		ans %= MOD;
		cout << ans << endl;
		return 0;
	}
	s.push_back(s[0] + 1);
	vector<int>num(s.size() + 1);
	for (int i = 0; i <= s.size(); i++) {
		num[i] = s[i] == s[0];
		if (i)num[i] = num[i] * (num[i - 1] + 1);
	}
	int fst = 0;
	int m = MOD;
	bool even = true;
	for (int i = 1; i < s.size()-1; i++) {
		if (!num[i] && num[i - 1]) {
			if (num[i - 1] & 1) {
				even = false;
				m = min(m, num[i - 1]);
			}
			if (fst == 0) {
				fst = num[i - 1];
				if (fst % 2 == 0)m = MOD;
			}
		}
	}
	if (even) {
		m = fst + 2;
	}
	else if (fst % 2 == 0) {
		m = min(m, fst+2);
	}
	if (m & 1)m++;
	//cout << m << endl;
	vector<long long int>dp(N + 2);
	vector<long long int>sum(N + 2);
	for (int i = 2; i <= m; i += 2)dp[i] = i;
	for (int i = 2; i <= N; i++) {
		dp[i] += sum[i - 2] + MOD;
		if (i - m - 2 >= 0)dp[i] -= sum[i - m - 2];
		dp[i] %= MOD;
		if (i == N) {
			cout << dp[i] << endl;
			return 0;
		}
		sum[i] = sum[i - 2] + dp[i];
		sum[i] %= MOD;
	}
}


Measured memory_bytes: 4500
#include <vector>
#include <algorithm>
#include <iostream>
#include <array>
#include <set>
#include <iomanip>
#include <map>

using namespace std;

int main()
{
    string line;
    getline(cin, line);
    sort(line.begin(), line.end());
    if (line == "abc")
    {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
#define F first
#define S second
int main() {
	int n, m;
	while (scanf("%d",&n)) {
		if (n==0) break;
		P ich[n];
		for (int i=0; i<n; i++) scanf("%d%d",&ich[i].F,&ich[i].S);
		scanf("%d",&m);
		P ji[m];
		for (int i=0; i<m; i++) scanf("%d%d",&ji[i].F,&ji[i].S);
		P mat[n+m];
		for (int i=0; i<n; i++) mat[i]=ich[i];
		for (int i=0; i<m; i++) mat[i+n]=ji[i];
		sort(mat, mat+n+m);
		int dp[n+m], res=0;
		dp[0]=1;
		for (int i=1; i<n+m; i++) {
			dp[i]=1;
			for (int j=0; j<i; j++) {
				if (mat[j].F<mat[i].F&&mat[j].S<mat[i].S) dp[i]=max(dp[i],dp[j]+1);
			}
			res=max(res,dp[i]);
		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;


class Program
{
	//mod（10^9 + 7）
	static readonly long mod = 1000000007;

	//Main
	static void Main(string[] args)
	{
		int S = int.Parse(Console.ReadLine());

		//dp
		long[] dp = new long[S+1];
		if(S >= 3){
			dp[3] = 1;
		}

		for(int i=4; i<S+1; i++){
			//i単体の場合、1通り
			dp[i] ++;

			//単体ではない場合、今までのケツに玉を加えるイメージ
			/*
			3つ前の並びのケツに3つ玉を加え、
			4つ前のケツに4個加え etc...
			*/
			for(int j=i-3; j>=3; j--){
				dp[i] += dp[j];
				dp[i] %= mod;
			}
		}

		long ans = dp[S];

		if(ans < 0){
			ans += mod;
		}
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 17536
#include <stdio.h>
int main()
{
	int i = -1, j, n, r, o, m = r = o = 0;
	struct {int n, s, r;} t[256], w;
	while (m++, i++, scanf("%d,%d", &t[i].n, &t[i].s))
		if (!t[i].n && !t[i].s) break;
	for (i = 0; i < m-1; i++)
		for (j = 0; j < m-2; j++)
			if (t[j].s < t[j+1].s)
				w = t[j], t[j] = t[j+1], t[j+1] = w;
	for (i = 0; i < m; t[i].r = r, i++)
		if (t[i].s != o)
			r++, o = t[i].s;
	for (i = 0; i < m-1; i++)
		for (j = 0; j < m-2; j++)
			if (t[j].n > t[j+1].n)
				w = t[j], t[j] = t[j+1], t[j+1] = w;
	while (scanf("%d", &n) != -1)
		printf("%d\n", t[n-1].r);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;

int main() {
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	int cnt = k;

	while (cnt <= b) {
		if (cnt >= a && cnt <= b) {
			cout << "OK" << endl;
			return 0;
		}
		cnt += k;
	}

	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3620
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int a=0;
		boolean judge=true;
		for(int i=0;i<n;i++)
		{
			String str=in.next();
			int x=in.nextInt();
			if(str.equals("("))
				a+=x;
			else
				a-=x;
			if(a<0)
				judge=false;
			
		}
		System.out.println(judge&&a==0 ? "YES":"NO");
	}

	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j, k) for (int i = j; i < k; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 60);

int a[200200];
int ans[200200];
vi to[200200];
vector<stack<int>> vs(200200, stack<int>());
vector<int> dp(200200, inf);
int N;

void dfs(int u, int p = -1) {
    int val = a[u];

    int idx = lower_bound(all(dp), val) - dp.begin();
    dp[idx] = val;

    vs[idx].push(val);
    ans[u] = lower_bound(all(dp), inf) - dp.begin();

    // cout << u << ": " << ans[u] << ": ";
    // rep(i, 0, N) if (dp[i] != inf) cout << dp[i] << " ";
    // cout << endl;

    for (auto v : to[u]) {
        if (v == p) continue;
        dfs(v, u);
    }
    vs[idx].pop();
    if (vs[idx].size() > 0) {
        dp[idx] = vs[idx].top();
    } else {
        dp[idx] = inf;
    }
}

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

    cin >> N;
    rep(i, 0, N) cin >> a[i];
    rep(i, 0, N - 1) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        to[u].push_back(v);
        to[v].push_back(u);
    }

    dfs(0);

    rep(i, 0, N) {
        cout << ans[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 168900
N,S = map(int,input().split())
x = -1
y = -1
z = -1
for i in range(N+1):
  for j in range(N+1):
    if N-(i+j) >= 0 and S == ( 10000*i + 5000*j + 1000*(N-(i+j)) ):
      x = i
      y = j
      z = N-(i+j)
      break
print(x,y,z)

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

vector<long long> makedivisor(long long n) {
    vector<long long> divisor;
    long long tmp = pow(n, 0.5) + 1;
    for (long long i = 1; i < tmp; i++) {
        if (n % i == 0) {
            divisor.push_back(i);
            if (i != n / i) {
                divisor.push_back(n / i);
            }
        }
    }
    sort(divisor.begin(), divisor.end());
    return divisor;
}

ll gcd(ll a, ll b) {
    if (a % b == 0) return b;
    return gcd(b, a % b);
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll A, B; cin >> A >> B;
    vector<ll> a = makedivisor(A);
    vector<ll> b = makedivisor(B);
    ll cnt = 0;
    set<ll> p;
    for (ll x : a) {
        for (ll y : b) {
            if (x == y) {
                p.insert(x);
            }
        }
    }
    vector<ll> t;
    for (auto itr = p.begin(); itr != p.end(); ++itr)
    {
        //cout << *itr;
        t.pb(*itr);
    }
    // for (ll x : t) {
    //     for (ll y : t) {
    //         if (x != y && gcd(x, y) == 1) {
    //             cout << x << ' ' << y << endl;
    //             cnt++;
    //         }
    //     }
    // }
    vector<ll> g;
    int f = 0;
    rep(i, t.size()) {
        ll tmp = t[i];
        rep(j, g.size()) {
            ll k = gcd(tmp, g[j]);
            if (k != 1) {
                f = -1;
                break;
            }
        }
        if (f == -1) {
            f = 0;
            continue;
        }
        f = 0;
        g.pb(tmp);
    }
    cout << g.size() << endl;
    
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(long long N, std::vector<long long> A) {}

int main() {
  long long max1 = 0;
  long long max2 = 0;
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    if (max1 < A[i]) {
      max2 = max1;
      max1 = A[i];
    } else {
      if (max2 < A[i]) {
        max2 = A[i];
      }
    }
  }
  rep(i, N) {
    if (A[i] == max1) {
      cout << max2 << endl;
    } else {
      cout << max1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  
  string abc = "ABC";
  int count = 0;
  
  for (int i = 0; i < n;){
    if (s.substr(i, 3) == abc) {
      count += 1;
      i += 3;
    } else {
      i += 1;
    }
  }
  
  cout << count << endl;
}


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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  
  vector<int> v(n, k-q);
  
  for(int i=0; i < q; i ++){
    int a;
    cin >> a;
    
    v.at(a-1) ++;
  }
  
  for(int i = 0; i < n; i++){
    if(v.at(i)>0){
      cout << "Yes" << endl;
    }
    
    else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// doot diddly donger cuckerino Hahahahahah

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef tuple<int, int, int> TPL;
typedef priority_queue<int> pqueue;
typedef priority_queue<int, VI, greater<>> pdqueue;

#define sim template<class T
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define UNIQUE(X) sort(ALL(X)); (X).erase(unique(ALL(X)),(X).end())
#define F first
#define S second
#define SZ(x)           (int)(x).size()
#define ALL(a)         std::begin(a), std::end(a)
#define Sort(x)         sort(ALL(x))
#define Fill(n, x)      memset(n,x,sizeof(n))
#define IN_REP         int _t; cin >> _t ; while(_t--)
#define IOS            ios::sync_with_stdio(false);cin.tie(NULL)
#define FOR(i, a, b)    for(int i=(a);i<(b);i++)
#define REP(i, n)       FOR(i,0,n)
#define FORR(i, n)      for(int i=(n);i>=0;i--)
#define EPS (double) 1e-9
#define MOD (LL)(1000*1000*1000 + 7)
#define cerr2(x,y) cerr << (x) << " " << (y) << endl;
#define cout2(x,y) cout << (x) << " " << (y) << endl;
const LD PI = acos(-1);
sim>T gcd(T x, T y) {return (y==0)?x:gcd(y, x % y);}
sim>void mini(T &a, T b) { a = min(a, b); }
sim>void maxi(T &a, T b) { a = max(a, b); }
sim>inline void add(T &x, T y) {x += y;if (x >= MOD) x -= MOD;}
sim>inline void sub(T &x, T y) {x -= y;if (x < 0) x += MOD;}
sim>inline T mul(T a, T b) {LL x = (long long) a * b;x %= MOD;return x;}
sim>inline T power(T base, T exp) {T result = 1; while (exp) {if (exp & 1)result *= base;exp >>= 1;base *= base;}return result;}
sim>inline T power(T a, T b, T mod) {T res = 1;while (b > 0) {if (b & 1) { res = mul(res, a); }a = mul(a, a);b >>= 1;}return res%mod;}
sim>inline T modInverse(T n, T p) { return power(n, p - 2, p)%p; }
sim, class U>string to_string(pair<T, U> p) {return "" + to_string(p.F) + " " + to_string(p.S) + "";}


class ALimitedInsertion {
public:
    void solve(std::istream &cin, std::ostream &cout) {
        int n;
        cin >> n;
        VI b(n),a;
        REP(i,n)cin >> b[i];
        while (!b.empty()) {
            int found = 0;
            for (int i = SZ(b) - 1; i >= 0; i--) {
	            if(b[i] == i+1){
	                a.PB(i+1);
	                b.erase(b.begin()+i);
	                found = 1;
	                break;
	            }
            }
            if(!found){
                cout << "-1\n";
                return;
            }
        }
        reverse(ALL(a));
        for(int i : a)cout << i << "\n";
    }
};


int main() {
    IOS;
	ALimitedInsertion solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

//グラフ関連
struct Edge {
    ll to, cap, rev;
    Edge(ll _to, ll _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph &G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    ll t = x / d;
    if(t >= k) {
        cout << x - k * d << en;
        return;
    }
    x -= d * t;
    k -= t;
    if(k % 2) {
        x -= d;
    }
    cout << abs(x) << en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    while(t--)*/
    solve();

    return 0;
}


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

int N,K;


// index が条件を満たすかどうか
bool isOK(int mid, vector<int> A) {
  int cnt = 0;
  rep(i,N) {
    cnt += (A[i] -1) / mid;
  }
  
  if ( cnt <= K ) 
    return true;
  else 
    return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(vector<int> A) {
  int ng = 0; 
  int ok = (int)(1e9+1); 

  /* ok と ng のどちらが大きいかわからないことを考慮 */
  while (abs(ok - ng) > 1) {
    int mid = (ok + ng) / 2;

    if (isOK(mid, A)) ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin >> N >> K;
  vector<int> A(N,0);
  rep(i,N) { cin >> A.at(i); }
  int ans = binary_search(A);
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 5488
n,y=map(int,input().split())
y=y//1000
ans10=-1
ans5=-1
ans1=-1
for i in range(y//10+2):
    num=n-i
    num2=y-(i*10)
    if num<=num2:
        num3=num2-num
        if num3%4==0 and num3//4<=num:
            ans10=i
            ans5=num3//4
            ans1=num-ans5
            break
print(ans10,ans5,ans1)


Measured memory_bytes: 9120
a, b, h, m = [int(e) for e in input().split()]
import math

x = ((a*math.cos(math.pi/6*(h+m/60))-b*math.cos(math.pi/30*m))**2 + (a*math.sin(math.pi/6*(h+m/60))-b*math.sin(math.pi/30*m))**2 )**(1/2)

print(x)

Measured memory_bytes: 9564
/*

solution:
 lps == lcs( s, s')

 */

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define re register
#define il inline
#define inf 0x3f3f3f

const int maxn = 333;

char s[maxn];
int f[maxn][maxn][maxn], k, n;

int main() {
  scanf("%s%d", s + 1, &k);
  n = strlen(s + 1);

  for (int i = 1; i <= n; ++i)
    f[i][i][0] = 1;

  for (int l = 1; l <= n; ++l)
    for (int i = 1; i + l <= n; ++i)
      for (int p = 0, j = i + l; p <= k; ++p) {
        f[i][j][p] = max(f[i + 1][j][p], f[i][j - 1][p]);

        if (s[i] == s[j])
          f[i][j][p] = max(f[i][j][p], f[i + 1][j - 1][p] + 2);

        if (p)
          f[i][j][p] = max(f[i][j][p], f[i + 1][j - 1][p - 1] + 2);
      }

  int ans = 0;
  for (int i = 0; i <= k; i++)
    ans = max(ans, f[1][n][i]);

  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 130816
s=list(input())
t=list(input())
dp=[[0]*(3030) for j in range(3030)]
ans=[]
memo=-1
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j]:
             dp[i+1][j+1] = dp[i][j]+1
             if memo < i:
                 ans.append(t[j])
                 memo = i

        else:
            dp[i+1][j+1] =max(dp[i][j+1],dp[i+1][j])

#print(dp[len(s)][len(t)])
answer=[]
i,j=len(s),len(t)
d=dp[i-1][j-1]
while i>=0 and j>=0:

    if dp[i-1][j]==dp[i][j]:
        i-=1
    elif dp[i][j-1]==dp[i][j]:
        j-=1
    else:
        answer.append(s[i - 1])
        i -= 1
        j -= 1
print("".join(reversed(answer)))

Measured memory_bytes: 115420
N = int(input())
al = [int(a) for a in input().split()]

ans = 0

c_minus = 0
abs_min = 1e10

for i in range(N):
    a = al[i]
    if a < 0:
        c_minus += 1
    if abs(a) < abs_min:
        abs_min = abs(a)
    ans += abs(a)
    
if c_minus % 2 == 0:
    print(ans)
else:
    print(ans - 2 * abs_min)

Measured memory_bytes: 14332
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int A;
    int B;
    cin >> A >> B;

    cout << A * B << endl;
    return 0;
}

Measured memory_bytes: 3588
import numpy as np

N, M = list(map(int, input().split()))

P = []
Y = []
for i in range(M):
    p, y = list(map(int, input().split()))
    P.append(p)
    Y.append(y)

Y_argsort = np.argsort(Y)

ans = ["tmp" for x in range(len(Y))]
cnt = [0 for x in range(N)]

for ya in Y_argsort:
    pref_id_padded = '{0:06d}'.format(P[ya])
    city_id = cnt[(P[ya] - 1)] + 1
    cnt[(P[ya] - 1)] += 1
    city_id_padded = '{0:06d}'.format(city_id)
    tmp_id = str(pref_id_padded) + str(city_id_padded)
    ans[ya] = tmp_id

for a in ans:
    print(a)


Measured memory_bytes: 39328
import sys

c0 = c1 = c2 = c3 = 0

for x in sys.stdin:
    a,b,c  = map(int,x.split())
    L = [a,b,c]
    L.sort()

    if L[2] < L[0] + L[1]:
        c0 += 1
        if L[2]**2 == L[0]**2 + L[1]**2:
            c1 += 1
        elif L[2]**2 < L[0]**2 + L[1]**2:
            c2 += 1
        elif  L[2]**2 > L[0]**2 + L[1]**2:
            c3 += 1
    else:
        break
print(c0,c1,c2,c3)



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

int main() {
  double a, b, x, s;
  cin >> a >> b >> x;
  x /= a;
  if(x > a * b / 2){
    s = a * b - x;
    cout << fixed << setprecision(10) << atan2(s*2/a, a) * 180 / 3.1415926535 << endl;
  }
  else{
    cout << fixed << setprecision(10) << 90 - atan2(x*2/b, b) * 180 / 3.1415926535 << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
from fractions import Fraction




def main():
    a, b , c = map(int, input().split())
    if a / c <= b:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()



Measured memory_bytes: 77200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i, n) for (i = 0; i < n; i++)
#define rrep(i, n) for (i = n; i >= 0; i--)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
 
const int mod = 1000000007;
 
int main() {
    int n;
    scanf("%d", &n);
 
    long long ans = 1; int i;
    rep(i, n) {
        ans *= i + 1;
        ans %= mod;
    }
 
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, ll> P;
#define MOD (1000000007ll)
#define l_ength size

int main(void){
	int a,b,c,d,cnt[110],ans=0,i;
	fill(cnt,cnt+110,0);
	cin >> a >> b >> c >> d;
	cnt[a]++;
	cnt[b]--;
	cnt[c]++;
	cnt[d]--;
	for(i=1; i<=100; ++i){
		cnt[i] += cnt[i-1];
	}
	for(i=0; i<=100; ++i){
		if(cnt[i] == 2){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val ar0 = Array.fill(n / 2)(0)
  val ar1 = Array.fill(n / 2)(0)
  val map = Range(0, n).map((_, sc.nextInt()))
    .map(t => if (t._1 % 2 == 0) ar0(t._1 / 2) = t._2 else ar1(t._1 / 2) = t._2)

  val or0 = ar0.toSeq.groupBy(i => i)
    .map(t => (t._1, t._2.length))
    .toSeq.sortBy(_._2).reverse

  val or1 = ar1.toSeq.groupBy(i => i)
    .map(t => (t._1, t._2.length))
    .toSeq.sortBy(_._2).reverse

  if (or0(0)._1 == or1(0)._1) {
    if (or0.length == 1) {
      if (or1.length == 1) {
        println(n / 2)
      } else {
        println(n / 2 - or1(1)._2)
      }
    } else {
      if (or1.length == 1) {
        println(n / 2 - or0(1)._2)
      } else {
        println(math.min(n - or1(0)._2 - or0(1)._2, n - or1(1)._2 - or0(0)._2))
      }
    }
  } else {
    val ans = n - or0(0)._2 - or1(0)._2
    println(ans)
  }

}


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

Measured memory_bytes: 256
// Shift-JIS（シフトジス）

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

int main()
{
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    long long ans = 5 + ((N - 1) / min({A, B, C, D, E}));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int int64_t
#define rep(i, N) for(int i=0; i<N; i++)
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
// " ", ' '
// std::string str;
// str = std::to_string(int i);
// bitset<3> s(N);

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

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

	int N, K, Q; cin >> N >> K >> Q;
	vec ps(N+1, 0);
	vec A(Q+1);
	rep(i, Q) {
		cin >> A.at(i);
		A.at(i) -= 1;
	}

	rep(i, Q) {
		ps.at(A.at(i)) += 1;
	}
	
	rep(i, N) {
		if(K-Q+ps.at(i) > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            int ans = 0;

            for(int i = 0; i < str.Length; i++)
            {
                if(str[i] == '2')
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140
use std::io;


fn main() {

    let mut line = String::new();
    let _ = io::stdin().read_line(&mut line);
    let split: Vec<&str> = line.split_whitespace().collect();

    let a: i64 = split[0].parse().unwrap();
    let b: i64 = split[1].parse().unwrap();
    let c: i64 = split[2].parse().unwrap();
    let r = byomocha(a,b,c);
    println!("{}",r);

}

fn byomocha(a: i64 ,b: i64,c: i64) -> String {
    if c <= (a+b) {
        return "Yes".to_string();
    } else {
        return "No".to_string();
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int s[1111][1111];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x,y,X,Y;cin>>x>>y>>X>>Y;
		s[x][y]++;
		s[x][Y]--;
		s[X][y]--;
		s[X][Y]++;
	}
	for(int i=0;i<=1000;i++)
	{
		for(int j=1;j<=1000;j++)s[i][j]+=s[i][j-1];
	}
	for(int j=0;j<=1000;j++)
	{
		for(int i=1;i<=1000;i++)s[i][j]+=s[i-1][j];
	}
	int ans=0;
	for(int i=0;i<=1000;i++)for(int j=0;j<=1000;j++)ans=max(ans,s[i][j]);
	cout<<ans<<endl;
}



Measured memory_bytes: 7440
N,X = map(int,input().split())
M = []
for i in range(N):
    m_i = int(input())
    M.append(m_i)
rX = X - sum(M)
count = N
while True:
    mincost = min(M)
    mincost_index = M.index(mincost)
    newcount = rX // mincost
    count += newcount
    rX = rX % mincost
    del M[mincost_index]
    min2cost = min(M)
    if rX < min2cost:
        print(count)
        exit()
    

Measured memory_bytes: 3060