akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define db double
using namespace std;
mt19937 rd(time(0));
const int M=2e5+10;
int n;
int b[M],vis[M],ans[M];
pair<int,int> a[M];
bool cmp(int x,int y){return x>y;}
int main()
{
    srand(time(0));
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i].first),a[i].second=i;
    for(int i=0;i<n;i++) scanf("%d",&b[i]);
    sort(a,a+n);
    sort(b,b+n,cmp);
    int i=0,j=0;
    while(i<n)
    {
        int o=0;
        while((a[i].first==b[j] || vis[j]) && o<2*n) j=(j+1)%n,o++;
        if(a[i].first==b[j] || vis[j]) break;
        ans[a[i].second]=b[j],vis[j]=1;
        i++;
    }
    if(i==n)
    {
        puts("Yes");
        for(int i=0;i<n;i++)
            printf("%d ",ans[i]);
        //puts("?");
        exit(0);
    }
    sort(b,b+n);
    for(int i=0;i<n;i++) vis[i]=0;
    i=0,j=0;
    while(i<n)
    {
        int o=0;
        while((a[i].first==b[j] || vis[j]) && o<2*n) j=(j+1)%n,o++;
        if(a[i].first==b[j] || vis[j]) break;
        ans[a[i].second]=b[j],vis[j]=1;
        i++;
    }
    if(i==n)
    {
        puts("Yes");
        for(int i=0;i<n;i++)
            printf("%d ",ans[i]);
        exit(0);
    }
    //int t=10;
    //while(t--)
    //{
    //    random_shuffle(b,b+n);
    //    for(int i=0;i<n;i++) vis[i]=0;
    //    i=0,j=0;
    //    while(i<n)
    //    {
    //        int o=0;
    //        while((a[i].first==b[j] || vis[j]) && o<2*n) j=(j+1)%n,o++;
    //        if(a[i].first==b[j] || vis[j]) break;
    //        ans[a[i].second]=b[j],vis[j]=1;
    //        i++;
    //    }
    //    if(i==n)
    //    {
    //        puts("Yes");
    //        for(int i=0;i<n;i++)
    //            printf("%d ",ans[i]);
    //        exit(0);
    //    }
    //}
    puts("No");
    return 0;
}


Measured memory_bytes: 7720
#include <iostream>
using namespace std;
int main() {
  int d,n;
  cin >> d >> n;
  int ans = 1;
  for (int i = 0; i < d; i++) ans *= 100;
  if (n == 100) {
    ans *= n+1;
  } else {
    ans *= n;
  }
  cout << ans << endl;
  return 0;
}

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

int count_d(long long int h){
	if(h == 1) return 1;
	else return 1 + count_d(h/2);
}

int main(){
	long long int h;
	cin >> h;
	int tmp = count_d(h);
	long long int p2 = 1;
	
	long long int ans = 0;
	for(int i=0; i < tmp; i++){
		ans += p2;
		p2 *= 2ll;
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
sample = [0] * 100

for i in range(1,N+1):

    num = str(i)
    first = num[0]
    final = num[-1]
    
    sample[int(first+final)] += 1

ans = 0

for i in range(1,10):
    for j in range(1,10):
        ans += sample[int(str(i)+str(j))] * sample[int(str(j)+str(i))]

print(ans)


    


Measured memory_bytes: 3060
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

min_val = 1000
for i, x in enumerate(H):
    val = abs(A - (T - x*0.006))
    if min_val > val:
        res = i+1
        min_val = val

print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
	int a, b;
	cin >> a >> b;
	if(a <= 0 && b >= 0){
		cout << "Zero" << endl;
	}else if(a >= 0 || (b - a) % 2 == 1){
		cout << "Positive" << endl;
	}else{
		cout << "Negative" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)


int main(){
    int n,m;
    cin >> n >> m;
    int x,y;
    switch(n){
        case 1:x=0;break;
        case 2:x=2;break;
        case 3:x=0;break;
        case 4:x=1;break;
        case 5:x=0;break;
        case 6:x=1;break;
        case 7:x=0;break;
        case 8:x=0;break;
        case 9:x=1;break;
        case 10:x=0;break;
        case 11:x=1;break;
        case 12:x=0;break;
    }
    switch(m){
        case 1:y=0;break;
        case 2:y=2;break;
        case 3:y=0;break;
        case 4:y=1;break;
        case 5:y=0;break;
        case 6:y=1;break;
        case 7:y=0;break;
        case 8:y=0;break;
        case 9:y=1;break;
        case 10:y=0;break;
        case 11:y=1;break;
        case 12:y=0;break;
    }

    cout << (x==y?"Yes":"No") << endl;
}








Measured memory_bytes: 384
N = int(input())
A = [int(input()) for i in range(N)]
f = max(A)
if A.count(f) >=2:
    for i in range(N):
        print(f)
else:
    M = A.index(f)
    del A[M]
    for i in range(M):
        print(f)
    print(max(A))
    for i in range(M+1,N):
        print(f)

Measured memory_bytes: 12532
#include<stdio.h>

int main(void)
{
        int i;
        int a,b,c,sum;

        scanf("%d%d%d",&a,&b,&c);

        sum = 0;
        for(i=0;sum<=100*a;i++){
                sum += a;
                if(sum%b==c){
                        printf("YES\n");
                        return 0;
                }
        }

        printf("NO\n");
        return 0;
}


Measured memory_bytes: 128
# coding: utf-8
# Your code here!
import math
a,b,C=map(int,input().split())

θ=math.radians(C)

h=b*math.sin(θ)
S=(a*h)/2
c=((a**2)+(b**2)-2*a*b*math.cos(θ))**0.5
L=a+b+c

print(S)
print(L)
print(h)


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
using ll = long long;
using vi = vector<int>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    int h, w;
    cin >> h >> w;
    string board[h];
    REP(i, h) cin >> board[i];

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

    REP(i, h) {
        REP(j, w) {
            if(board[i][j] == '.') continue;
            bool ok = false;
            REP(k, 4) {
                int ni = i + dx[k];
                if(ni < 0 or ni >= h) continue;
                int nj = j + dy[k];
                if(nj < 0 or nj >= w) continue;
                if(board[ni][nj] == '#') {
                    ok = true;
                    break;
                }
            }
            if(!ok) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    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 < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  map<int, int> mp;
  REP(i, N){
    cin >> A[i];
    mp[A[i]]++;
    if(mp[A[i]] > 1){
      cout << "NO"<< endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 10368
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long a = long.Parse(input[0]);
		long b = long.Parse(input[1]);
    long c = long.Parse(input[2]);
		long k = long.Parse(input[3]);
		Console.WriteLine((k % 2 == 0) ? a-b : b-a);
	}
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
using namespace std;
int n,A,B;
int cnt[1<<17],s[1<<17];
main()
{
	cin>>n>>A>>B;
	if(__builtin_popcount(A^B)%2==0)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	else
	{
		cout<<"YES"<<endl;
	}
	for(int i=0;i<n;i++)cnt[i]=1<<i;
	int rc=__builtin_popcount(A^B);
	for(int k=2;k<rc;k+=2)cnt[k-1]++,cnt[k]--;
	int id[20]={};
	int sz=0;
	for(int i=0;i<n;i++)
	{
		if((A^B)>>i&1)
		{
			id[sz++]=i;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(((A^B)>>i&1)==0)id[sz++]=i;
	}
	int pr[1<<17]={};
	pr[0]=1;
	int now=0;
	for(int i=0;i<(1<<n)-1;i++)
	{
		int mi=-1;
		for(int j=0;j<n;j++)
		{
			if(cnt[j]>0&&pr[now^(1<<id[j])]==0&&(mi<0||cnt[j]>cnt[mi]))mi=j;
		}
		cnt[mi]--;
		now^=1<<id[mi];
		pr[now]=1;
		s[i]=1<<id[mi];
	}
	now=A;
	for(int i=0;i<1<<n;i++)
	{
		cout<<now<<(i==(1<<n)-1?"\n":" ");
		if(i<(1<<n)-1)now^=s[i];
	}
}

Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>
#include<queue>

using namespace std;

int head(int n){
	int k=n;
	while(n/10!=0){
		k=n/10;
		n/=10;
	}
	return k;
}

int main(){

	int ans=0;
	int n;
	cin>>n;

	int bhead=0,btail=0;
	int count[100][100];

	for(int i=11;i<100;i++){
		if(i%10==0)continue;
		bhead=i%10;
		btail=head(i);
		for(int j=btail;j<=n;j+=10){
			if(head(j)==bhead)count[btail][bhead]++;
		}
	}

	int atail=0,ahead=0;
	for(int i=1;i<=n;i++){
		if(i%10==0)continue;
		ahead=head(i);
		atail=i%10;
		ans+=count[ahead][atail];
		//cout<<ahead<< "  "<<atail<<"  "<<count[ahead][atail]<<endl;
	}

	cout<<ans;

	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K,Q;cin >> N >> K >> Q;
  vector<int> v(N,K);
  rep(i,Q){
    int x;cin >> x;
    --x;
    ++v[x];
  }
  rep(i,N) YesNo(v[i]-Q>0);
  return 0;
}


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

int main() {
  int N, min = 1000;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int A, count = 0;
    cin >> A;
    while (A % 2 == 0) {
      A /= 2;
      count += 1;
    }
    if (min > count) {
      min = count;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#define MAX 105
#define INF -1
int p[MAX+1],m[MAX+1][MAX+1];
int min(int x,int y){
  if(x<y) return x;
  else return y;
}
int main(){
  int n,i,j,l,k,q;
  scanf("%d",&n);
  for(i=1;i<=n;i++) scanf("%d %d",&p[i-1],&p[i]);

  for(i=1;i<=n;i++) m[i][i]=0;
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=(1<<21);
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	m[i][j]=min(m[i][j],q);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N;
    string s;
    cin >> N;
    cin >> s;
    char ans[N];
    char c[2] = {'S', 'W'};
    rep(i, 2){
        rep(j, 2) {
            ans[0] = c[i];
            ans[1] = c[j];
            REP(k, 2, N) {
                if (ans[k-1] == 'S' && ans[k-2] == 'S' && s[k-1] == 'o' || ans[k-1] == 'W' && ans[k-2] == 'W' && s[k-1] == 'o' || ans[k-1] == 'S' && ans[k-2] == 'W' && s[k-1] == 'x' || ans[k-1] == 'W' && ans[k-2] == 'S' && s[k-1] == 'x') {
                    ans[k] = 'S';
                } else {
                    ans[k] = 'W';
                }
            }
            if ((s[0] == 'o' && ans[N-1] == 'S' && ans[1] == 'S' && ans[0] == 'S' || s[0] == 'o' && ans[N-1] == 'W' && ans[1] == 'W' && ans[0] == 'S' || s[0] == 'o' && ans[N-1] == 'W' && ans[1] == 'S' && ans[0] == 'W' || s[0] == 'o' && ans[N-1] == 'S' && ans[1] == 'W' && ans[0] == 'W' || s[0] == 'x' && ans[N-1] == 'S' && ans[1] == 'W' && ans[0] == 'S' || s[0] == 'x' && ans[N-1] == 'W' && ans[1] == 'S' && ans[0] == 'S' || s[0] == 'x' && ans[N-1] == 'S' && ans[1] == 'S' && ans[0] == 'W' || s[0] == 'x' && ans[N-1] == 'W' && ans[1] == 'W' && ans[0] == 'W') && (s[N-1] == 'o' && ans[N-1] == 'S' && ans[N-2] == 'S' && ans[0] == 'S' || s[N-1] == 'o' && ans[N-1] == 'S' && ans[N-2] == 'W' && ans[0] == 'W' || s[N-1] == 'o' && ans[N-1] == 'W' && ans[N-2] == 'S' && ans[0] == 'W' || s[N-1] == 'o' && ans[N-1] == 'W' && ans[N-2] == 'W' && ans[0] == 'S' || s[N-1] == 'x' && ans[N-1] == 'S' && ans[N-2] == 'W' && ans[0] == 'S' || s[N-1] == 'x' && ans[N-1] == 'S' && ans[N-2] == 'S' && ans[0] == 'W' || s[N-1] == 'x' && ans[N-1] == 'W' && ans[N-2] == 'S' && ans[0] == 'S' || s[N-1] == 'x' && ans[N-1] == 'W' && ans[N-2] == 'W' && ans[0] == 'W')) {
                rep(k, N){
                    cout << ans[k];
                }
                cout << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;

}

Measured memory_bytes: 640
using System;
using System.IO;
using System.Linq;

namespace AGC034
{
    class B
    {
        static void Main(string[] args)
        {

            //StreamReader sr = new StreamReader(@"testcase");
            //string s = sr.ReadLine();
            string s = Console.ReadLine();
            s = s.Replace("BC", "D");
            string[] S = s.Select(x => x.ToString()).ToArray();
            long dcount = 0;
            long res = 0;

            // TLE
            /*
            for (int i = S.Length - 2; i >= 0; i--)
            {
                if (S[i] == "A")
                {
                    index = i + 1;
                    while (index < S.Length && S[index] == "D")
                    {
                        index++;
                        count++;
                    }

                    if (0 < count)
                    {
                        S[i] = "D";
                        S[index - 1] = "A";
                    }
                    res += count;
                }
                count = 0;
            }
             */

            for (int i = S.Length - 1; i >= 0; i--)
            {
                if (S[i] == "A")
                {
                    res += dcount;
                }
                else if (0 < i && S[i] == "D" && (S[i - 1] == "D" || S[i - 1] == "A"))
                {
                    dcount++;
                }
                else
                {
                    dcount = 0;
                }
            }
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 28892
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define F first
#define S second
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e9;
/************************  DEFINE  ****************************/

int main(){
    int n;cin>>n;
    if(n == 1 || n == 2){ cout << 1 << endl; return 0;}

    vector<int> a(n); rep(n) cin >> a[i];
    int up = 0; int c = 1;
    for(int i = 1;i < n;i++){
        if(up == 0 && a[i] - a[i-1] == 0) continue; 
        else if(up == 0 && a[i] - a[i-1] > 0) up++;
        else if(up == 0 && a[i] - a[i-1] < 0) up--;
        else if(up > 0 && a[i] - a[i-1] > 0) up++;
        else if(up < 0 && a[i] - a[i-1] < 0) up--;
        else if(up > 0 && a[i] - a[i-1] < 0){up = 0; c++;}
        else if(up < 0 && a[i] - a[i-1] > 0){up = 0; c++;}
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void){
    double radius;
    double area,circumference;
    static const double pi = 3.141592653589793;
    
    cin >> radius;
    area = radius * radius * M_PI;
    circumference = 2 * radius * M_PI;
    cout << fixed;
    cout << setprecision(6);
    cout << area << " " << circumference << endl;
}


Measured memory_bytes: 3276
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
//	cin>>n>>k;
//	cout<<n<<k<<endl;
//string S[100];
//43

int main(){
	string in;cin>>in;
	string ans;

	for(int i=0;i<in.size();i++){
		//cout<<"else"<<endl;
		if (in[i]=='1'){

			ans+='1';
		}else if(in[i]=='0'){

			ans+='0';
		}else if(in[i]=='B' && ans.size()!=0){

			ans.erase(ans.end()-1);

		}
	}
	//in.erase(in.begin()+1);
	cout<<ans<<endl;
	return 0;

}

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

int main(){
    string s;
    cin>>s;
    if (s=="SUN") cout<<'7';
    else if (s=="SAT") cout<<'1';
    else if (s=="FRI") cout<<'2';
    else if (s=="THU") cout<<'3';
    else if (s=="WED") cout<<'4';
    else if (s=="TUE") cout<<'5';
    else if (s=="MON") cout<<'6';
}

Measured memory_bytes: 256
from collections import defaultdict


def resolve():
    n, m = list(map(int, input().split()))
    d = defaultdict(list)
    for _ in range(m):
        a, b = map(int, input().split())
        d[a].append(b)
    if n in d[1]:
        print("POSSIBLE")
        return 0
    for i in d[1]:
        if n in d[i]:
            print("POSSIBLE")
            return 0
    print("IMPOSSIBLE")
    return 0


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 84824
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a,b;
  cin>>a>>b;
  cout<<max(max(a+b,a-b),a*b)<<endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define int long long
#define ll long long
#define str string
#define db double
#define ac() cout<<"Yes"<<endl
#define wa()  cout<<"No"<<endl
#define ddd cout<<"---debug---"<<endl;
#define ff(a,b) for(signed long long (a)=1;(a)<=(b);(a)++)
#define fff(a,b) for(signed long long (a)=0;(a)<(b);(a)++)
#define re readdd()
#define pr(a) printtt(a)
#define pee puts("");
#define eee putchar(' ');
#define pss(a) push_back(a)
#define ps(a) push(a)
#define SZ(x) x.size()
#define epp empty()
#define all(x) x.begin(),x.end()
typedef vector<int> VE;
int gcd(int a,int b){return b==0?a:gcd(b,a%b);}//
int ppow(int a,int b,int mod){a%=mod;//
int ans=1%mod;while(b){if(b&1)ans=(long long)ans*a%mod;
a=(long long)a*a%mod;b>>=1;}return ans;}
int readdd(){int x=0,f=1;char c=getchar();//
while(!isdigit(c)&&c!='-')c=getchar();
if(c=='-')f=-1,c=getchar();
while(isdigit(c))x=x*10+c-'0',c=getchar();
return f*x;}
void printtt(int x){if(x<0)putchar('-'),x=-x;
if(x>=10)printtt(x/10);putchar(x%10+'0');}
bool addd(int a,int b){return a>b;};
//
const int maxm=1e5+5;
int a[maxm];
signed main(){
    memset(a,-1,sizeof a);
    int n=re,m=re;
    ff(mm,m){
        int x=re,xx=re;
        if(a[x]!=-1&&a[x]!=xx){
            puts("-1");return 0;
        }
        a[x]=xx;
    }
    if(a[1]==-1&&n!=1)a[1]=1;
    if(n==1&&a[1]==-1)a[1]=0;
    ff(i,n){
        if(a[i]==-1)a[i]=0;
    }
    if(n!=1&&a[1]==0){
        puts("-1");return 0;
    }
    ff(i,n)pr(a[i]);
    return 0;
}


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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int n;
    cin >> n;

    vector< string > s;
    vector< long long int > t;

    for ( long long int i = 0; i < n; i++ ) {
        string ins;
        long long int in_t;
        cin >> ins >> in_t;
        s.push_back( ins );
        t.push_back( in_t );
    }

    string ss;
    cin >> ss;

    long long int ans = -1;
    for ( long long int i = 0; i < n; i++ ) {
        if ( s[i] == ss ) {
            ans = 0;
        } else if ( ans < 0 ) {
        } else {
            ans += t[i];
        }
    }
    cout << ans << endl;

    return 0;

}


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

int main()
{
  int a,b;
  cin >> a >> b;
  
  if(a * b % 2 == 0) {
    cout << "Even" <<endl;
  }
  
  else{
    cout << "Odd" <<endl;
  }
  return 0;
}

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

using namespace std;

int main(){

    double n,d;

    cin >> n >> d;
    
    double  x,y;
    double dis=d*d;
    int cont=0;
    double p,q;
    
    for(double i=0;i<n;i++){
           cin >> x >> y;
            p=x*x;
            q=y*y;
           if(p + q <= dis){
               cont++;
           
            }
    }

    cout << cont;
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 3712
while True:
    H, W = map(int, raw_input().split())
    if H == 0 and W == 0:
        break
    print("#" * W)
    for i in range(1, H - 1):
        print("#" + "." * (W - 2) + "#")
    if H != 1:
        print("#" * W)
    print("")

Measured memory_bytes: 4212
#include <iostream>

using namespace std;

int main() {
    int sets[4][10000];
    int n, x;
    int i = 0;
    while(1) {
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        int counter = 0;


        for(int j = n; j >= 3; j--) {
                for( int k = j-1; k >= 2; k--) {
                    for(int l = k-1; l >= 1; l--) {
                        int sum = j+k+l;
                        if(x == sum)  counter++;
                    }
                }
            }
        cout << counter << endl;
    }
    


    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<queue>

using namespace std;

int n;
int u,k,t;
int d[100];
int dis=0;
int inf = -1;
vector<int> G[100];
queue<int> q;

void bfs(int x){
    q.push(x);
    while(!q.empty()){
        int u = q.front();q.pop();
        for(int i=0;i<G[u].size();i++){
            int v = G[u][i];
            if(d[v] == inf){
                d[v] = d[u] + 1;
                q.push(v);
            }
        }
    }
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> u >> k;
        u--;
        for(int j=0;j<k;j++){
            cin >> t;
            t--;
            G[u].push_back(t);
        }
    }
    fill(d,d+n,inf);
    d[0] = 0;
    bfs(0);
    for(int i=0;i<n;i++){
        cout << i+1 << " " << d[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <cmath>

using namespace std;

int a[10010];

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
        scanf("%d",&a[i]);
        int s=0;
    for(int i=0;i<m;i++)s+=a[i];
        if(s>n){
            printf("-1\n");
        }else{
            printf("%d\n",n-s);
        }
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////
const ll nmax = 1000006; 
ll mob[nmax]; ll comp[nmax];ll phi[nmax]; 
void calcomp()
{
	for(ll i = 2; i<nmax; i++)
	{
		if(comp[i]==0)
		{
			for(ll j = i*i; j<nmax; j+=i)
			comp[j]=1; 
		}
	}
	comp[0]=1; comp[1]=1; 
}
void calmob()
{   lp(i,0,nmax)
{
	mob[i]=1; 
}
	mob[1]=1;
	for(ll i = 2; i<nmax; i++)
	{   
      ll s = sqrt(i); 
      if(s*s==i)
      {
      	for(ll j = i; j<nmax; j+=i)
      	mob[j]=0; 
	  }
	  else if(comp[i]==0)
	  {  
	  	for(ll j = i; j<nmax; j+=i)
	  	mob[j]*=(-1); 
	  }
	}
}
void calphi()
{
	for(ll i = 1; i<nmax; i++)
	{
		for(ll j = i; j<nmax; j+=i)
		{
			phi[j]+=(i*mob[j/i]); 
		}
	}
}
void solve()
{  ll n , k; 
	  cin>>n>>k; 
	  
	calcomp(); calmob(); calphi(); 
	ll ans =0 ; 
for(ll i = 1; i<=k; i++)
{
	ans = (ans+(phi[i]*(poww(k/i,n)))%mo)%mo; 
}
cout<<ans<<endl; 
}
int main()
{ ios; 

ll t ;t =1; 
 while(t--)
	solve(); 
	return 0 ; 
}

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

bool compB(const pair<ll, ll> a, const pair<ll, ll> b) {
	return a.second > b.second;
}

int main()
{
	ll N, H;
	cin >> N >> H;
	vector<pair<ll, ll>> ABi(N);
	
	rep(i, N) {
		int a, b;
		cin >> a >> b;
		ABi[i] = make_pair(a, b);
	}
	//投げる強さ順にソート
	sort(ABi.begin(), ABi.end(), compB);
	//最大切りつけ力計算
	ll aMax = 0;
	for (auto a : ABi) {
		aMax = max(aMax, a.first);
	}

	//一本ずつなげて計算
	ll hp = H;
	ll turn = 0;
	while (hp > 0) {
		if (turn >= ABi.size() || ABi[turn].second < aMax) {
			turn += (hp / aMax);
			if (hp % aMax > 0) {
				turn++;
			}
			break;
		} else {
			hp -= ABi[turn].second;
		}
		turn++;
	}
	//出力
	cout << turn << endl;

	return 0;
}


Measured memory_bytes: 1792
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
N,M=map(int,input().split())
uf = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
print(len(uf.roots())-1)

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> piipii;

const ll INF = 1e18;
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back

int a[200005];
struct st{
    ll st[800010], lazy[800010];
    void init(int n){
        for(int i=1;i<=4*n;i++){
            st[i] = 1e18;
            lazy[i] = 0;
        }
    }
    void push(int n, int s, int e, ll v){
        st[n] += v;
        if(s != e){
            lazy[n+n] += v;
            lazy[n+n+1] += v;
        }
        lazy[n] = 0;
    }
    void update(int n, int s, int e, int l, int r, ll v){
        push(n, s, e, lazy[n]);
        if(s > r || l > e) return;
        if(l <= s && e <= r){
            push(n, s, e, v);
            return;
        }
        int mid = (s+e)/2;
        update(n+n, s, mid, l, r, v);
        update(n+n+1, mid+1, e, l, r, v);
        st[n] = min(st[n+n], st[n+n+1]);
    }
    ll query(int n, int s, int e, int l, int r){
        push(n, s, e, lazy[n]);
        if(s > r || l > e) return 2e18;
        if(l <= s && e <= r) return st[n];
        int mid = (s+e)/2;
        return min(query(n+n, s, mid, l, r), query(n+n+1, mid+1, e, l, r));
    }
}st1, st2;

pii p[200005];
int idx[200005];
int main(){
    int n, q;
    scanf("%d%d%d%d", &n, &q, &a[1], &a[2]);
    for(int i=1;i<=q;i++) scanf("%d", &a[i+2]);
    q+=2;
    st1.init(q);
    st2.init(q);
    for(int i=1;i<=q;i++) p[i] = pii(a[i], i);
    sort(p+1, p+1+q);
    for(int i=1;i<=q;i++) idx[p[i].se] = i;

    st1.update(1, 1, q, idx[1], idx[1], -INF+0-a[1]);
    st2.update(1, 1, q, idx[1], idx[1], -INF+0+a[1]);
    for(int i=3;i<=q;i++){
        ll res = min(st1.query(1, 1, q, 1, idx[i])+a[i], st2.query(1, 1, q, idx[i], q)-a[i]);
        st1.update(1, 1, q, 1, q, abs(a[i-1]-a[i]));
        st2.update(1, 1, q, 1, q, abs(a[i-1]-a[i]));

        st1.update(1, 1, q, idx[i-1], idx[i-1], -st1.query(1, 1, q, idx[i-1], idx[i-1])+res-a[i-1]);
        st2.update(1, 1, q, idx[i-1], idx[i-1], -st2.query(1, 1, q, idx[i-1], idx[i-1])+res+a[i-1]);
    }
    ll ans = 2e18;
    for(int i=1;i<=q-1;i++) ans = min(ans, st1.query(1, 1, q, idx[i], idx[i])+a[i]);
    printf("%lld\n", ans);
}

Measured memory_bytes: 28416
from collections import defaultdict

n, m = list(map(int, input().split()))
ps = []
ys = []

ken_dict = defaultdict(list)

for _ in range(m):
    p, y = list(map(int, input().split()))
    ps.append(p)
    ys.append(y)
    ken_dict[p].append(y)

n_dict = {}

for key in ken_dict:
    ken_dict[key].sort()
    for i, value in enumerate(ken_dict[key]):
        n_dict[(key, value)] = 1 + i

for i in range(m):
    print(str(ps[i]).zfill(6) + str(n_dict[ps[i], ys[i]]).zfill(6))


Measured memory_bytes: 92756
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;

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; }

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };

int main()
{
	int h, w;
	cin >> h >> w;
	Vs G(h);
	queue<the> Q;

	int bcnt = 0;
	//初期値
	rep(i, h)  cin >> G[i];
	rep(i, h) {
		rep(j, w) {
			if (G[i][j] == '#') {
				Q.push({ i,j });
				bcnt++;
			}
		}
	}

	int ans = 0;
	int cnt = 0;
	int nbcnt = 0;
	while (!Q.empty()) {
		the v = Q.front();
		Q.pop();
		cnt++;
		//cout << cnt << " " << bcnt << " " << nbcnt << endl;
		for (int i = 0; i < 4; i++) {
			the nv = { v.first + dx[i],v.second + dy[i] };
			if (nv.first < 0 || nv.first >= h || nv.second < 0 || nv.second >= w) continue;
			if (G[nv.first][nv.second] == '#') continue;
			Q.push(nv);
			G[nv.first][nv.second] = '#';
			nbcnt++;
		}
		if (bcnt == cnt) {
			ans++;
			cnt = 0;
			bcnt = nbcnt;
			nbcnt = 0;
		}
	}
	ans--;
	cout << ans << endl;
}


Measured memory_bytes: 13152
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

int n, m;
int a[50], b[50];
bool gragh[50][50];
bool visited[50];

void dfs(int v) { //深さ優先
	visited[v] = true; //すでに訪れた
	for (int i = 0; i < n; i++) {
		if (gragh[v][i] == false) continue; //連結がないなら
		if (visited[i] == true) continue; //すでに訪れたなら
		dfs(i);
	}
}

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

	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		gragh[a[i]][b[i]] = gragh[b[i]][a[i]] = true; //連結がある
	}

	int ans = 0; //橋の数

	for (int i = 0; i < m; i++) { //連結をなくしたときにdfsして未訪問があるならそれは橋である
		gragh[a[i]][b[i]] = gragh[b[i]][a[i]] = false; //連結をなくす

		for (int j = 0; j < n; j++) visited[j] = false; //初期化
		
		dfs(0); //深さ優先
		
		bool bridge = false;
		
		for (int j = 0; j < n; j++) {
			if (visited[j] == false) bridge = true; //未訪問があるなら橋がある
		}

		if (bridge) ans++;

		gragh[a[i]][b[i]] = gragh[b[i]][a[i]] = true; //連結を戻す
	}
	cout << ans << endl;
	return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

map<string, int64> w;

int64 num(string&s, int32& p){
	int64 ret = 0;
	while(isdigit(s[p])){
		ret = ret*10+s[p++]-'0';
	}
	return ret;
}

int64 atom(string& s, int32& p){
	string x = "";
	x += s[p++];
	if(islower(s[p])){
		x += s[p++];
	}
	if(w[x] == 0) return -1;
	return w[x];
}

int64 mole(string& s, int32& p){
	int64 ret = 0;
	while(p < s.size()){
		if(s[p] == '('){
			p++;
			int64 W = mole(s, p);
			if(W == -1) return -1;
			p++;
			if(isdigit(s[p]))
				W = W*num(s, p);
			ret += W;
		}else if(isupper(s[p])){
			int64 W = atom(s, p);
			if(W == -1) return -1;
			if(isdigit(s[p]))
				W = W*num(s, p);
			ret += W;
		}else{
			break;
		}
	}
	return ret;
}

int main(void){
	string s;
	while(cin >> s && s != "END_OF_FIRST_PART"){
		int32 W;
		cin >> W;
		w[s] = W;
	}
	while(cin >> s && s != "0"){
		int32 p = 0;
		int64 W = mole(s, p);
		if(W == -1)
			cout << "UNKNOWN" << endl;
		else
			cout << W << endl;
	}
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

string s, t;
int main() {
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define MAX 510000
#define MOD 1000000007

ll fac[MAX], finv[MAX], inv[MAX];
ll sta[MAX];

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}


void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
ll modinv(ll a, ll m){
  ll b=m,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=m;
  if(u<0) u+=m;
  return u;
}
signed main(){
  init_io();
  ll n,k;
  COMinit();
  cin >> n >> k;
  if(n-1<=k){
    k = n-1;
  }
  ll ans = 0;
  for(int i=0;i<=k;i++){
    ans += COM((n-1-i)+i,i)*COM(n,i);
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 14208
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


class DGraph:
    def __init__(self, n, edges):
        self._vertice = [{} for _ in range(n)]
        for e in edges:
            self._vertice[e[0]][e[1]] = e[2] if len(e) == 3 else 1

    def __len__(self):
        return len(self._vertice)

    def edges(self, n=None):
        srcs = range(len(self)) if n is None else [n]
        return sum([[(s, d, c) for d, c in self._vertice[s].items()] for s in srcs], [])

    def transpose(self):
        tedges = [(t, f, c) for f, t, c in self.edges()]
        return DGraph(len(self), tedges)

    def cost(self, src, dst):
        return self._vertice[src].get(dst, float('inf'))


def topological_sort(g):
    result = []
    status = [0] * len(g)

    def _dfs(v):
        st = [v]
        while 0 < len(st):
            cv = st[-1]
            if status[cv] == 0:
                status[cv] = 1
                for _, d, _ in g.edges(cv):
                    if status[d] == 1:
                        raise ValueError('has cyclic')
                    st.append(d)
            elif status[cv] == 1:
                status[cv] = 2
                result.append(cv)
            if status[cv] == 2:
                st.pop()

    for v in range(len(g)):
        _dfs(v)
    return list(reversed(result))


def solve(N: int, M: int, x: "List[int]", y: "List[int]"):
    es = [(xx-1, yy-1, 0) for xx, yy in zip(x,y)]
    g = DGraph(N, es)

    order = topological_sort(g)
    dp = [0] * N
    for i in order:
        for _, j, _ in g.edges(i):
            dp[j] = max(dp[j], dp[i] + 1)
    return max(dp)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    x = [int()] * (M)  # type: "List[int]" 
    y = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    result = solve(N, M, x, y)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 120792
#include <bits/stdc++.h>
template <typename T>
class SegmentTreeUpdMax {
    int n;
    const T inf_min = std::numeric_limits<T>::min();
    std::vector<T> node;
public:
    SegmentTreeUpdMax(std::vector<T> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n, inf_min);
        for(int i=0;i<sz;++i) node[i+n-1] = v[i];
        for(int i=n-2;i>=0;--i) node[i] = std::max(node[2*i+1], node[2*i+2]);
    }
    void update(int idx, T val) {
        assert(0 <= idx && idx < n);
        node[idx + n - 1] = val;
        idx = idx + n - 1;
        while(idx > 0) {
            idx = (idx - 1) / 2;
            node[idx] = std::max(node[2*idx + 1], node[2 * idx + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return inf_min;
        if(a <= l && r <= b) return node[k];
        T vl = query(a, b, k*2+1, l, ((l+r)/2));
        T vr = query(a, b, k*2+2, (l+r)/2, r);
        return std::max(vl, vr);
    }
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 998244353;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<P> v(n);
  for(int i=0;i<n;++i) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  vector<int> x(n), d(n);
  for(int i=0;i<n;++i) {
    x[i] = v[i].first;
    d[i] = v[i].second;
  }
  vll ma(n);
  ma[n-1] = x[n-1] + d[n-1];
  SegmentTreeUpdMax<ll> st(ma);
  for(int i=n-2;i>=0;--i) {
    auto it = upper_bound(x.begin(), x.end(), x[i]+d[i]-1);
    int pos = distance(x.begin(), it);
    ma[i] = max((ll)(x[i] + d[i]), st.query(i+1, pos));
    st.update(i, ma[i]);
  }
  vvi g(n+1);
  for(int i=0;i<n;++i) {
    g[i].push_back(i+1);
  }
  for(int i=0;i<n;++i) {
    auto it = lower_bound(x.begin(), x.end(), ma[i]);
    int pos = distance(x.begin(), it);
    g[i].push_back(pos);
  }
  vll dp(n+1);
  dp[0] = 1;
  for(int i=0;i<n;++i) {
    for(int j=0;j<(int)(g[i].size());++j) {
      int nxt = g[i][j];
      dp[nxt] += dp[i];
      dp[nxt] %= MOD;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 21604
<?php
$num = (int)trim(fgets(STDIN));
$arr = array_map(function($val){return (int)$val;}, explode(" ", fgets(STDIN)));

for ($i=1;$i<$num;$i++) {

        echo implode(" ", $arr), PHP_EOL;
  $v=$arr[$i];
  for ($j = $i-1; 0 <= $j and $arr[$j] > $v; $j--) {
    $arr[$j+1] = $arr[$j];
    $arr[$j] = $v;
  }
}

echo implode(" ", $arr), PHP_EOL;

Measured memory_bytes: 15256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int>arr(n);
	for(int i=0; i<n; i++)
	 cin>>arr[i];
	int last=arr[0];
	for(int i=k; i<n; i++){
		if(arr[i]>last){
			last=arr[i-k+1];
			cout<<"Yes\n";
		}
		else
		{
			cout<<"No\n";
			last=arr[i-k+1];
		}
	}
	return 0;
}

Measured memory_bytes: 4044
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define ci cin
#define co cout
#define ed endl
#define vc vector
#define sr string
#define pb push_back
#define st(a,n) sort(a,a+n)
#define ms(a) memset(a,0,sizeof(a))
#define fr(i,k,n) for(int i=k;i<=n;++i)
#define FR(i,n,k) for(int i=n;i>=k;--i)
#define inf 0x3f3f3f3f
#define mod 10000019
#define maxn 1000
#define exp 1e-6
typedef long long ll;
using namespace std;
int main()
{
    int n,k;
    ci>>n>>k;
    vector<string> v;
    fr(i,1,n)
    {
        string s;
        ci>>s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    vector<string>::iterator it=v.begin();
    while(it!=v.end())
            co<<*it++;
    co<<ed;
    return 0;
}


Measured memory_bytes: 256
import java.lang.Math.sqrt
val Int.absoluteValue: Int
    get() = if (this < 0) -this else this
val Int.sign: Int
    get() = when {
        this > 0 -> 1
        this == 0 -> 0
        this < 0 -> -1
        else -> TODO()
    }
fun <T: Comparable<T>> minOf(a: T, b: T): T {
    return if (a < b) a else b
}
inline fun <T> T.also(func: (T) -> Unit): T {
    func(this)
    return this
}
inline fun <T> T.run(func: T.() -> Unit): T {
    func(this)
    return this
}
fun main(args: Array<String>) {
    val n = readLine()!!.trim().toInt()
    val pointsA = Array(n){
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        Point(x, y)
    }.toMutableList().run {
        add(0, Point(0, 0))
        add(Point(1000, 0))
    }
    val m = readLine()!!.trim().toInt()
    val pointsB = Array(m){
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        Point(x, y)
    }.toMutableList().run{
        add(0, Point(0, 1000))
        add(Point(1000, 1000))
    }
    val edgesA = pointsA.indices.drop(1).map{Edge(pointsA[it], pointsA[it - 1])}
    val edgesB = pointsB.indices.drop(1).map{Edge(pointsB[it], pointsB[it - 1])}
    val minA = pointsA.flatMap{p -> edgesB.map{it.distance(p)}}.min()
    val minB = pointsB.flatMap { p -> edgesA.map { it.distance(p) } }.min()
    val minC = pointsA.first().distance(pointsB.first())
    println("%.10f".format(
            listOfNotNull(minA, minB, minC).min()!!
    )
    )
}

data class Point(val x: Int, val y: Int) {
    fun distance(that: Point): Double = (this - that).length
}
operator fun Point.minus(that: Point): Vector {
    return Vector(x - that.x, y - that.y)
}
data class Vector(val dx: Int, val dy: Int) {
    val length: Double
        get() = sqrt((dx * dx + dy * dy).toDouble())
    fun dot(that: Vector): Int = dx * that.dx + dy * that.dy
    fun cross(that: Vector): Int = dx * that.dy - dy * that.dx
}
data class Edge(val endA: Point, val endB: Point) {
    fun distance(point: Point): Double {
        return if (vec.dot(point - endB).sign * vec.dot(point - endA).sign <= 0) (a * point.x + b * point.y + c).absoluteValue / sqrt((a * a + b * b).toDouble())
        else minOf(endA.distance(point), endB.distance(point))
    }
    fun distance(that: Edge): Double {
        return listOf(distance(that.endA), distance(that.endB), that.distance(endA), that.distance(endB)).min()!!
    }
    private val vec: Vector = endA - endB
    private val a: Int = vec.dy
    private val b: Int = -vec.dx
    private val c: Int = -endB.y * b - endB.x * a
}



Measured memory_bytes: 34960
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
using namespace std;

string itos(int x){
  stringstream ss;
  ss << x;
  return ss.str();
}

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

  for(int SET = 1; SET <= T; SET++){
    printf("Case %d:\n", SET);

    int n;
    cin >> n;

    for(int i = 0; i < 10; i++){
      n *= n;
      string s = itos(n);

      while(s.length() != 8){
        s = "0" + s;
      }

      string ts = "";

      for(int i = 2; i <= 5; i++){
        ts += s[i];
      }

      n = atoi(ts.c_str());
      cout << n << endl;
    }
  }
}

Measured memory_bytes: 1260