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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // int t;
    // cin>>t;
    // while(t--){
        
    // }
    int n;cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int g=__gcd(i,j);
            for(int k=1;k<=n;k++){
                sum+=__gcd(g,k);
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"

using namespace std;

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

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

	vector<int> vec(n);
	for (auto &a : vec)
		cin >> a;

	for (int i = 0; i < vec.size(); i++) {
		if (vec[i] > i + 1)
			if (vec[vec[i] - 1] == i + 1)
				ans++;
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
const int N=1e3+5;
char s[N][N];
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
struct node{
    int y,x,s;
};
int ans;
queue<node>q;
int main(){
    int n,m;scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)if(s[i][j]=='#'){
            q.push((node){i,j,0});
        }
    }
    while(!q.empty()){
        node t=q.front();q.pop();
        ans=max(ans,t.s);
        for(int i=0;i<4;i++){
            int yy=dy[i]+t.y;
            int xx=dx[i]+t.x;
            if(yy<1||xx<1||yy>n||xx>m||s[yy][xx]=='#') continue;
            s[yy][xx]='#';
            q.push((node){yy,xx,t.s+1});
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 13328
S,T = (0..1).map{ 
  ss = [0]
  gets.chomp.chars.each{ |c| ss << (ss[-1] + (c == "A" ? +1 : -1)) }
  ss
}

N = gets.to_i
N.times{
  a,b,c,d = gets.split.map &:to_i
  puts (S[b]-S[a-1]) % 3 == (T[d] - T[c-1]) % 3 ? "YES" : "NO"
}


Measured memory_bytes: 20844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int p[3] = {0};
    bool ans = false;
    
    rep(i, N) {
        int a, cnt = 0;
        cin >> a;
        
        while(a) {
            if ((a % 2) == 1) {
                break;
            }
            
            cnt++;
            a /= 2;
        }
        
        p[min(2, cnt)]++;
    }
    
    if (((p[0] + p[1] % 2) <= (p[2] + 1))) {
        ans = true;
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


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

ll gcd(ll a, ll b) { if (!b)return a; return gcd(b, a%b); }
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
ll v[3000], len;
int main() {
	ll a;
	while (scanf("%lld", &a), a) {
		len = 0;
		for (ll i = 1; i*i <= a; i++) {
			if (a%i == 0) {
				v[len++] = i;
				if (i != a / i)v[len++] = a / i;
			}
		}
		sort(v, v + len);
		int cnt = 0;
		rep(i, len)for (int j = i; j < len; j++) {
			if (lcm(v[i], v[j]) == a)cnt++;
		}
		printf("%d\n", cnt);
	}
}

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

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

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

  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);

  rep(i, 0, m) {
    cin >> p[i] >> y[i];
    --p[i];
  }

  vector<vector<int>> va(n);
  rep(i, 0, m) pb(va[p[i]], y[i]);

  rep(i, 0, n) sort(all(va[i])), unique(va[i]);

  rep(i, 0, m) {
    int ans = p[i];
    printf("%06d", ans + 1);
    int id = lower_bound(all(va[ans]), y[i]) - va[ans].begin();
    printf("%06d\n", id + 1);
  }
  return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i, a, n) for ( i = a; i < (n); i++)
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define x first
#define y second
#define mp make_pair
#define pb push_back
using namespace std;
#define INF 1e6
int main(){
	fast;
	ll i,j,W,k,tc,q,n,flag;	
	cin>>n>>W;
	vector <ll> w(n),v(n);
	rep(i,0,n)
		cin >> w[i] >> v[i] ;

	ll totSum=0;
	rep(i,0,n){
		totSum += v[i];

	}
	ll aa = 1e14;
	ll dp[n+1][totSum+1];
	 rep(i,0,n+1){
		rep(j,0,totSum + 1 ){
			dp[i][j]=aa;
		}
	}

	dp[0][0]=0;
	rep(i,1,n+1){
		rep(j,0,totSum + 1 ){
			
			if(j==0){
				dp[i][j] = 0;
			}
			else if(v[i-1]<=j){
				dp[i][j] = min(dp[i-1][j],dp[i-1][j-v[i-1]] + w[i-1]);
			}
			else { dp[i][j] = dp[i-1][j]; }

		}
		
	}
	
	for(i = totSum ; dp[n][i]>W ; i--){
		;
	}
	cout<<i<<endl;

	
	// rep(i,0,n+1){
	// 	rep(j,0,totSum+1){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int main(){
	int n;
	scanf("%d",&n);int s=0,i=1;
	while(s<=n)s+=i++;
	s-=n;
	fore(k,1,i)if(k!=s)printf("%d\n",k);
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
    if ((p.at(i) > p.at(i - 1) && p.at(i) < p.at(i + 1)) || (p.at(i) < p.at(i - 1) && p.at(i) > p.at(i + 1))) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール
constexpr ll p = 1000000007LL;

// 処理内容
int main() {
    
    ll n, m; cin >> n >> m;
    vector<bool> can_step(n, true);
    REP(i, m) {
        ll a; cin >> a;
        can_step[a] = false;
    }
    vector<ll> dp(n+1, 0);
    dp[0] = 1;
    RANGE(i, 1, n) {
        if (!can_step[i]) continue;
        if (i-2 >= 0) dp[i] = (dp[i] + dp[i-2]) % p;
        if (i-1 >= 0) dp[i] = (dp[i] + dp[i-1]) % p;
    }
    cout << dp[n] << endl;
    
}

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


typedef long long int ll;

int main()
{
	int N , a , b;
	cin >> N;
	int flag = 0 , cnt = 0;
	while(N--)
	{
		cin >> a >> b;
		if(a == b)
			cnt++;
		else
			cnt = 0;

		if(cnt == 3)
		{
			flag = 1;
			
		}

	
	}

	if(flag == 1)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  string s;
  cin >> s;
  int n = sz(s);
  vi ans(n);
  rep(ri,2) {
    int cnt = 0;
    rep(i,n) {
      if(s[i] == 'R') cnt++;
      else {
        ans[i] += cnt/2;
        ans[i-1] += (cnt+1) / 2;
        cnt = 0;
      }
    }
    reverse(all(s));
    reverse(all(ans));
    rep(i,n) {
      if(s[i] == 'L') s[i] = 'R';
      else s[i] = 'L';
    }
  }
  rep(i,n) {
    cout << ans[i] << (i != n-1?' ':'\n');
  }
}

Measured memory_bytes: 1104
#include<stdio.h>
#define N 200
int main()
{
  int n,a,i,j,b,k;
  scanf("%d",&n);
  int arr[N][N];
  for(i=0;i<n;i++){
    scanf("%d",&a);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&b);
      arr[a][b]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(arr[i][j]!=1){
        arr[i][j]=0;
        printf("%d",arr[i][j]);
      }else{
        printf("%d",arr[i][j]);
      }
      if(j!=n)printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll N, M;
    cin >> N >> M;

    if ((N % 2) == 1){
        REP(i, M){
            cout << (i + 1) << " " << (N - i - 1) << endl;
        }
    }else{

        vector<P> v;
        int i = 1;
        while(v.size()<M+1){
            v.push_back(P(i, N + 1 - i));
            v.push_back(P(N / 2 - i, N / 2 + i));
            i++;
        }
        REP(i, M) cout << v[i].first << " " << v[i].second << endl;

    }

    return 0;
}

Measured memory_bytes: 4828
#include <stdio.h>

int main(void) {
    int a,b,c;
    int min;

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

    if(a+b < b+c) {
        min = a+b;
    } else {
	min = b+c;
    }

    if(a+c < min) {
	min = a+c;
    } 

    printf("%d\n",min);

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =2e5+10;
const int mod=1e9+7;

int a[maxn];
int b[maxn];
int dp[3010][2];


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,t;
    cin>>n>>t;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];

    }
    for(int i=1;i<=n;i++)
    {
        for(int j=t-1;j>=0;j--)
        {
            if(j>=a[i])
            {

                dp[j][1]=max(dp[j][1],max(dp[j-a[i]][1]+b[i],dp[j][0]+b[i]));
                dp[j][0]=max(dp[j][0],dp[j-a[i]][0]+b[i]);

            }
            else
            {
                dp[j][1]=max(dp[j][1],dp[j][0]+b[i]);
            }
        }
    }
    cout<<dp[t-1][1]<<'\n';




}


Measured memory_bytes: 3704
#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>

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

using namespace std;

int main() {
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    cout<< a[0] + a[1] <<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var w string
	fmt.Scan(&w)

	bucket := make(map[rune]int, len(w))
	for _, v := range w {
		bucket[v]++
	}

	for _, v := range bucket {
		if v%2 != 0 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
def main():
  S = input()
  Q = int(input())
  import sys
  que = [list(sys.stdin.readline().split()) for _ in range(Q)]
  pre=''
  post=''
  judge = False
  for l in que:
    if int(l[0])==1:
      if judge:
        judge = False
      else:
        judge = True

    elif int(l[0])==2:
      f,c = int(l[1]),l[2]
      if judge:
        if f==1:
          f=2
        elif f==2:
          f=1
      if f==1:
        pre = ''.join([pre,c])
      elif f==2:
        post = ''.join([post,c])

  pre = pre[::-1]
  S = pre+S+post
  if judge:
    S=S[::-1]
  print(S)
  
main()

Measured memory_bytes: 32196
#include <iostream>

using namespace std;

int main()
{
string N;
cin >>N ;
if(N.at(0)=='9')
    cout <<"Yes";
else
    if (N.at(1)=='9')
    cout << "Yes";
    else
    if (N.at(0)=='9'&&N.at(1)=='9')
        cout << "Yes";
else
cout <<"No";

return 0;
}


Measured memory_bytes: 256
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())

const int M=1000000007;
const int MM=998244353;


 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(m<=1)return 0;
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=2e5+5;

ll sp[N];

void fill(){
  for(int i=1;i<N;i++)sp[i]=i;

    for(int i=2;i<N;i++){
      for(int j=i;j<N;j+=i){
        if(sp[j]==j)sp[j]=i;
      }
    }
}

bool prime(ll x){
  if(x==2)return true;

for(ll i=2;i*i<=x;i++){
  if(x%i==0)return false;
}

  return true;
}


int main()
{ 

IOS;

ll n;cin>>n;

multiset<ll>s;

for(int i=0;i<n;i++){
ll x;cin>>x;
auto it=s.lb(x);
if(it==s.begin()){
  s.insert(x);
  continue;
}

it--;

s.erase(it);

s.insert(x);

}

cout<<s.size();



return 0;
 
}


Measured memory_bytes: 8308
#include <cstdio>

int main(){
    int n,a,b;
    scanf("%d %d %d",&n,&a,&b);
    int c;
    int d;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        c = i;
        d = 0;
        while(c != 0){
            d += c % 10;
            c = (c - c % 10) / 10;
        }
        if(a <= d && d <= b){
            ans += i;
        }
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 128
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

int main()
{
    char c;
    scanf("%c", &c);
    printf("%c\n", 'A' | c & 0x20);
    return 0;
}


Measured memory_bytes: 1668
N,Y = (int(x) for x in input().split())

ans=[-1,-1,-1]

for i in range(N+1):
    for j in range(N-i+1):
        if Y == 10000*i + 5000*j + 1000*(N-i-j):
            ans = [i,j,N-i-j]
            break
    else:
        continue
    break

print(ans[0],ans[1],ans[2])

Measured memory_bytes: 3064
local List = {}
function List.new ()
    return {first = 0, last = -1}
end

function List.pushleft (list, value)
    local first = list.first - 1
    list.first = first
    list[first] = value
end

function List.pushright (list, value)
    local last = list.last + 1
    list.last = last
    list[last] = value
end

function List.popleft (list)
    local first = list.first
    local value = list[first]
    list[first] = nil
    list.first = first + 1
    return value
end

function List.popright (list)
    local last = list.last
    local value = list[last]
    list[last] = nil
    list.last = last - 1
    return value
end

function List.empty (list)
    return list.first > list.last
end

----------

local h,w=io.read("n","n")
local ch,cw=io.read("n","n")
local dh,dw=io.read("n","n","l")

local s={}
for i=1,h do
    local input=io.read()
    s[i]={}
    for j=1,w do
        s[i][j]=input:sub(j,j)
    end
end

local checkin=List.new()
local checked=List.new()
List.pushright(checkin,{ch,cw})

local cost={}
local INF=10^13
for i=1,h do
    cost[i]={}
    for j=1,w do
        cost[i][j]=INF
    end
end
cost[ch][cw]=0
local dx={1,0,-1,0}
local dy={0,1,0,-1}

while (not List.empty(checkin)) or (not List.empty(checked)) do
    while not List.empty(checkin) do
        local q=List.popleft(checkin)
        List.pushright(checked,q)
        local x,y=q[1],q[2]
        for i=1,4 do
            local nx,ny=x+dx[i],y+dy[i]
            local checker=(nx<1 or nx>h or ny<1 or ny>w)
            if not checker and s[nx][ny]~="#"then
                if cost[x][y]<cost[nx][ny] then
                    cost[nx][ny]=cost[x][y]
                    List.pushright(checkin,{nx,ny})
                end
            end
        end
    end
    while not List.empty(checked) do
        local q=List.popleft(checked)
        local x,y=q[1],q[2]
        for dx=-2,2 do
            for dy=-2,2 do
                local nx,ny=x+dx,y+dy
                local checker=(nx<1 or nx>h or ny<1 or ny>w)
                if not checker and s[nx][ny]~="#"then
                    if cost[x][y]+1<cost[nx][ny] then
                        cost[nx][ny]=cost[x][y]+1
                        List.pushright(checkin,{nx,ny})
                    end
                end
            end
        end
    end
end

print(cost[dh][dw]<INF and cost[dh][dw] or -1)

Measured memory_bytes: 40076
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

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

	vector<int> S(n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &S[i]);
	}

	cin >> q;
	vector<int> T(q);
	for (int i = 0; i < q; i++)
	{
		scanf("%d", &T[i]);
	}

	int ans = 0;
	for (int i = 0; i < q; i++)
	{
		auto result = find(S.begin(), S.end(), T[i]);
		if (result != S.end())
		{
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3184
/*input
3
1 2 3
2
2 4
*/
macro_rules! input_vec {
    () => {
        input!()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };
    ($delimiter:expr) => {
        input!()
            .split($delimiter)
            .map(|x| x.parse().unwrap())
            .collect()
    };
}

macro_rules! input {
    () => {{
        let mut return_ = format!("");
        std::io::stdin().read_line(&mut return_).ok();
        return_.pop();
        return_
    }};
}

fn main() {
    input!();
    let a: Vec<i32> = input_vec!();
    input!();
    let b: Vec<i32> = input_vec!();
    let min = if a.len() > b.len() { b.len() } else { a.len() };
    for i in 0..min {
        if b[i] > a[i] {
            println!("1");
            std::process::exit(0);
        } else if a[i] > b[i] {
            println!("0");
            std::process::exit(0);
        }
    }
    if b.len() > a.len() {
        println!("1");
    } else {
        println!("0");
    }
}



Measured memory_bytes: 5032
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
//力技って楽よね
using namespace std;

int main(void) {
	int n;
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	
	long long int ans=100000000;

	for (int i = 0; i < 100; i++) {
		long long int temp = 0;
		for (int j = 0; j < n; j++) {
			temp += ((x[j] - i)*(x[j] - i));
		}
		ans = min(ans, temp);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,val[200100],res;
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)scanf("%lld",&val[i]);
	res+=accumulate(val+1,val+n+1,0ll);
	for(int i=2;i<=n;i++)val[i]=min(val[i],val[i-1]+m);
	for(int i=n-1;i;i--)val[i]=min(val[i],val[i+1]+m);
	printf("%lld\n",res+accumulate(val+1,val+n+1,0ll)-val[1]-val[n]+(n-1)*m);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
   ll N, K; cin >> N >> K;
   map<ll, ll> mp;
   rep(i, N) {
       ll a; cin >> a;
       ++mp[a];
   }

   vector<ll> A(N);
   for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
       A.emplace_back(itr->second);
   }
   sort(ALL(A));

   ll ans = 0;
   if (K < len(A)) {
       rep(i, len(A) - K) ans += A[i];
   }
   cout << ans << endl;
}

Measured memory_bytes: 18656
/**
 * Created by hiramekun at 11:15 on 2019-09-02.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    scanf("%lli", &n);

    ll v[1000][1000];

    rep(i, n) {
        rep(j, n - 1) {
            ll a;
            scanf("%lli", &a);
            a--;
            v[i][j] = a;
        }
    }
    ll rem = n * (n - 1);
    ll ans = 0;
    ll idxs[1000] = {0};

    while (rem > 0) {
        bool done[1000] = {false};

        bool plus = false;
        rep(i, n) {
            if (done[i]) continue;
            if (idxs[i] >= n - 1) continue;
            ll j = v[i][idxs[i]];
            if (done[j]) continue;
            if (j >= n - 1) continue;
            if (idxs[j] >= n - 1) continue;

            if (v[j][idxs[j]] == i) {
                done[i] = done[j] = true;
                idxs[i]++, idxs[j]++;
                rem -= 2;

                if (!plus) {
                    plus = true;
                    ans++;
                }
            }
        }
        if (!plus) {
            printf("%i", -1);
            return;
        }
    }
    printf("%lli", ans);
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 8064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	s, t := next(), next()

	b := []byte(s)
	for i := 0; i < len(s); i++ {
		if string(append(b[i:], b[:i]...)) == t {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

Measured memory_bytes: 640
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    int n;
    cin>>n;
    map<vector<int>,int> mp;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        vector<int> v(26);
        for(auto &c:s) v[c-'a']++;
        mp[v]++;
    }

    ll res=0;
    for(auto &e:mp){
        res+=ll(e.second)*(e.second-1)/2;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 18944
function main(input) {
  input = input.trim();
  const a = input.split("\n");
  const co =a[0].split(" ");
  const num = a[1].split(" ").map(Number);
  if(co[0] == a[2]){
    num[0]--;
  }else{
    num[1]--;
  }
	console.log(num[0]+" "+ num[1]);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#include <iostream>

#include <iostream>
#include <vector>
#include <algorithm>

class EStringsOfImpurity
{
public:
    void solve(std::istream& in, std::ostream& out)
    {
        std::string s;
        in >> s;
        const int n = s.length();
        std::vector<std::pair<char, int>> pos;
        std::vector<int> mark(256), last(256);
        for (int i = 0; i < n; ++i)
            pos.emplace_back(s[i], i), mark[s[i]] = 1, last[s[i]] = i;
        std::sort(pos.begin(), pos.end());
        std::string t;
        in >> t;
        int lastp = -1;
        long long ans = 0;
        for (char c : t)
        {
            if (!mark[c])
            {
                out << "-1\n";
                return;
            }
            if (last[c] <= lastp)
            {
                ans += n - 1 - lastp;
                lastp = -1;
            }
            auto it = std::upper_bound(pos.begin(), pos.end(), std::make_pair(c, lastp));
            ans += it->second - lastp;
            lastp = it->second;
            // out << lastp << ' ' << ans << '\n';
        }
        out << ans << '\n';
    }
};


int main()
{
    std::ios_base::sync_with_stdio(0);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    in.tie(0);
    EStringsOfImpurity solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 1484
# 1 "g.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "g.cpp"
# 1 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 1
       
# 12 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/bits/stdc++.h" 1
 #include <bits/stdc++.h>
# 13 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/assoc_container.hpp" 1
 #include <ext/pb_ds/assoc_container.hpp>
# 14 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2
# 1 "/home/tysm/dev/cpplib/bin/../stdlib/ext/pb_ds/tree_policy.hpp" 1
 #include <ext/pb_ds/tree_policy.hpp>
# 15 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp" 2







using namespace std;
using namespace __gnu_pbds;

using ii = pair<long long, long long>;
using vi = vector<long long>;
using vd = vector<long double>;
using vb = vector<bool>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvd = vector<vd>;
using vvb = vector<vb>;
using vvii = vector<vii>;
# 50 "/home/tysm/dev/cpplib/bin/../include/cpplib/stdinc.hpp"
inline long long mod(const long long n, const long long m = ((long long)1e9+7)){
    return (n%m + m)%m;
}

/**
 * Euclidean GCD.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long gcd(const long long a, const long long b){
    if(a < 0 or b < 0)
        return gcd(abs(a), abs(b));
    if(a == 0)
        return b;
    return gcd(b%a, a);
}

/**
 * Euclidean derivated LCM.
 *
 * Time Complexity: O(log(min(a, b))).
 * Space Complexity: O(log(min(a, b))).
 */
long long lcm(const long long a, const long long b){
    // same as a*b/gcd(a, b) but avoiding overflow.
    return a/gcd(a, b)*b;
}
# 2 "g.cpp" 2

void dfs(vvi &adj, vi &ans, long long u, long long p = -1){
    ans[u] = 0;
    for(long long v:adj[u]){
        if(v == p)
            continue;
        if(ans[v] == -1)
            dfs(adj, ans, v, u);
        ans[u] = max(ans[u], ans[v]+1);
    }
}

int32_t main(){
    (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL));
    long long n, m;
    cin >> n >> m;
    vvi adj(n+1);
    for(long long i=0; i<m; ++i){
        long long a, b;
        cin >> a >> b;
        adj[a].push_back(b);
    }
    vi ans(n+1, -1);
    for(long long i=1; i<=n; ++i){
        if(ans[i] == -1)
            dfs(adj, ans, i);
    }
    cout << *max_element(ans.begin(), ans.end()) << "\n";
    return 0;
}


Measured memory_bytes: 9984
#include<stdio.h>
int main()
{	int  s1,s2,a,b,c,d;;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	s1=a*b;
	s2=c*d;
	printf("%d\n",s1>s2?s1:s2);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double ave;
        double s;
        while(true) {
            double sum=0;
            double tmp=0;
            int num = sc.nextInt();
            if (num == 0) break;
            int[] score = new int[num];
            for (int i = 0; i < num; i++) {
                score[i] = sc.nextInt();
                sum += (double)score[i];
            }
            ave = sum / (double) num;
            for (int i = 0; i < num; i++) {
                tmp += Math.pow((double) score[i] - ave, 2.0);
            }
            s = Math.sqrt(tmp / num);
            System.out.printf("%.8f\n", s);
        }
    }
}



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

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

  map<string,int> mp;

  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    mp[s]++;
  }

  long long ans=0;
  for(auto p : mp){
    int i = p.second;
    ans += (long long)i*(i-1) / 2;
  }

  cout << ans << endl;
}


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

int main() {
	int n;
	cin >> n;
	int k = 0,mh = 0;
	for(int i = 0;i < n;i++)
	{
		int h;
		cin >> h;
		if(h >= mh)
		{
			k++;
			mh = h;;
		}
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define llint long long

using namespace std;

llint N;
llint a[300005];

int main(void)
{
	cin >> N;
	for(int i = 0; i < 3*N; i++) cin >> a[i];
	sort(a, a+3*N);
	reverse(a, a+3*N);
	
	llint ans = 0;
	for(int i = 0; i < N; i++) ans += a[2*i+1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
s = input()
dict = {}
for i in range(len(s)):
  if s[i] in dict:
    dict[s[i]] += 1
  else:
    dict[s[i]] = 1
flg = True
for v in dict.values():
  if v%2 > 0:
    flg = False
    break
if flg:
  print('Yes')
else:
  print('No')

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

int main(){
	int N;
	cin >> N;
	int large,small;
	large = N / 100;
	small = N % 10;
	if(large==small){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll h,w;
  cin >> h >> w;
  mat a(h,vec(w));
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      cin >> a[i][j];
    }
  }
  vec sx,sy,gx,gy;
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      if(a[i][j]%2==0||(j==w-1&&i==h-1)) continue;
      a[i][j]--;
      sy.push_back(i+1);
      sx.push_back(j+1);
      if(j==w-1) {
        a[i+1][j]++;
        gx.push_back(j+1);
        gy.push_back(i+2);
      }
      else {
        a[i][j+1]++;
        gx.push_back(j+2);
        gy.push_back(i+1);
      }
    }
  }
  cout << sy.size() << endl;
  for(ll i=0;i<sy.size();i++) {
    cout << sy[i] << " " << sx[i] << " " << gy[i] << " " << gx[i] << endl;
  }
}

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

int main(){
    int n;cin>>n;
    ll ans=0;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n;i++) cin>>c[i];
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    for(int i=0;i<n;i++){
        auto iter=lower_bound(a.begin(),a.end(),b[i]);
        ll index1=iter-a.begin();
        auto it=upper_bound(c.begin(),c.end(),b[i]);
        ll index2=it-c.begin();
        ans+=index1*(n-index2);
    }
    cout<<ans<<endl;
}

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

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

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    int A, B; cin >> A >> B;
    
    cout << A * B << endl;

    return 0;
}

Measured memory_bytes: 3596
import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		Queue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
		
		pq.add(sc.nextInt());
		pq.add(sc.nextInt());
		pq.add(sc.nextInt());
		
		int q  = sc.nextInt();
		while(q-->0){
			pq.add(2*pq.poll());
		}
		int ans = 0;
		while(pq.size()>0){
			ans+=pq.poll();
		}
		System.out.println(ans);
		// your code goes here
	}
}

Measured memory_bytes: 21844
def f_xor_matching(M, K):
    if K >= 2**M:
        return -1

    if M == 0:
        ans = [0, 0]
    elif M == 1:
        ans = [0, 0, 1, 1] if K == 0 else [-1]
    else:
        b = [k for k in range(2**M) if k != K]
        ans = b + [K] + b[::-1] + [K]
    return ' '.join(map(str, ans))

M, K = [int(i) for i in input().split()]
print(f_xor_matching(M, K))

Measured memory_bytes: 28428
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iomanip>
using namespace std;
 
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
 
template <class T> int LIS(vector<T> &a) {
    T INF = numeric_limits<T>::max() / 2;
    vector<T> res(a.size()+1,INF);
    for (int i = 0; i < a.size(); i++) {
        *(lower_bound(res.begin(),res.end(),a[i])) = a[i];
    }
    for (int i = 0; i < a.size(); i++) {
        if (res[i] == INF) return i;
    }
    return (int) a.size();
}
 
 
int main() {
 
    ll x1,y1,x2,y2;
    ll N;
    vector<ll> X,Y;
 
    cin >> x1 >> y1 >> x2 >> y2;
    cin >> N;
 
    X.resize(N);
    Y.resize(N);
    REP(i,N) cin >> X[i] >> Y[i];
 
    bool dir;
    if (x1 <= x2 && y1 <= y2) dir = true;
    if (x1 <= x2 && y1 > y2) dir = false;
    if (x1 > x2 && y1 <= y2) dir = false;
    if (x1 > x2 && y1 > y2) dir = true;
 
    ll u = max(y1,y2);
    ll d = min(y1,y2);
    ll l = min(x1,x2);
    ll r = max(x1,x2);
 
    vector< pair<ll,ll> > arr;
    REP(i,N) {
        if (X[i] >= l && X[i] <= r && Y[i] >= d && Y[i] <= u) {
            if (!dir) Y[i] *= -1;
            arr.push_back(make_pair(X[i],Y[i]));
        }
    }
 
    sort(arr.begin(), arr.end());
 
    vector<ll> lis;
    REP(i,arr.size()) lis.push_back(arr[i].second);
 
    ll cross = LIS<ll> (lis);
    ll t = abs(x1 - x2) + abs(y1 - y2);
 
    double ans;
 
    if (x1 == x2 || y1 == y2) {
        ans = (double) t * 100.0;
        if (cross > 0) {
            ans -= 20.0;
            ans += M_PI * 10.0;
        }
        cout << fixed << setprecision(15) << ans << endl;
        return 0;
    }
 
 
    ll over = min(abs(x1 - x2) + 1, abs(y1 - y2) + 1);
 
    ans = (double) t * 100.0;
    ans -= 20.0 * (double) cross;
    ans += M_PI * (double) cross / 2.0 * 10.0;
 
 
    if (over == cross) {
        ans -= M_PI * (double) 1.0 / 2.0 * 10.0;
        ans += M_PI * 10.0;
    }
 
    //cout << cross << endl;
 
    cout << fixed << setprecision(15) << ans << endl;
 
    return 0;
}


Measured memory_bytes: 10860
// Last Change: 03/21/2019 22:43:11.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  string S;
  cin >> S;
  map<char, int> abc;
  abc['a'] = 1;
  abc['b'] = 10;
  abc['c'] = 100;

  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    ans += abc[S[i]];
  }

  if (ans == 111) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 256
n,k=map(int,input().split())
dp=[0 for i in range(n+1)]
acc=[0 for i in range(n+1)]
dp[1]=1
mod=998244353
acc[1]=1
l,r=[],[]
for i in range(k):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)
for i in range(2,n+1):
    for j in range(k):
        if i-l[j]<0:
            continue
        dp[i]+=(acc[i-l[j]]-acc[max(0,i-r[j]-1)])
        dp[i]%=mod
    acc[i]=(acc[i-1]+dp[i])%mod
print(dp[-1])

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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int maxelemid = max_element(a.begin(), a.end()) - a.begin();
  int maxelem = *max_element(a.begin(), a.end());

  long long half, half2;
  half = (maxelem + 1) / 2;
  if ((maxelem + 1) % 2 == 0) half2 = (maxelem + 1) / 2 - 1;

  long long difmin = 1e10;
  long long difminid = -1;
  for (int i = 0; i < n; i++) {
    if (i == maxelemid) continue;
    long long diff = abs(a[i] - half);
    if ((maxelem + 1) % 2 == 0) diff = min(diff, abs(a[i] - half2));
    if (difmin > diff) {
      difmin = diff;
      difminid = i;
    }
  }
  cout << maxelem << " " << a[difminid] << endl;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);

 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int a = Integer.parseInt(st.nextToken());
 		int b = Integer.parseInt(st.nextToken());
 		out.println(a*b);
 		out.close();
 		
 	}

}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25432
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum, k, q;
ll color[ohara];
V g[ohara];

bool dfs(ll v, ll c) {
  color[v] = c;
  rep(i, Size(g[v])) {
    if (color[g[v][i]] == c) return false;
    if (color[g[v][i]] == 0 && !dfs(g[v][i], -c)) return false;
  }
  return true;
}

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

  cin >> n >> m;
  rep(i, m) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    g[a[i]].p_b(b[i]);
    g[b[i]].p_b(a[i]);
  }
  int ok = 1;
  rep(i, n) {
    if (color[i] == 0) {
      if (!dfs(i, 1)) {
        ok = 0;
        break;
      }
    }
    if (!ok) break;
  }
  if (!ok) {
    ans = n * (n - 1) / 2;
  } else {
    ll cou1 = 0, cou2 = 0;
    rep(i, n) {
      if (color[i] == 1)
        cou1++;
      else
        cou2++;
    }
    ans = cou1 * cou2;
  }
  Cout(ans - m);
  return 0;
}

Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;
}

Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    mod = 10**9+7
    if n - k == -1:
        print(1)
    else:
        ans = (n+2*k) * (n-k+1) * (n-k+2) // 6 + n - k + 2
        print(ans%mod)
if __name__=="__main__":
    main()


Measured memory_bytes: 9140
#include <cstdio>
#include <cmath>
#include <iostream>

using namespace std;

#define PI (M_PI / 180)

int main() {
    int d, a, r = 90;
    double x = 0.0, y = 0.0;
    while (1) {
        scanf("%d, %d", &d, &a);
        if (d == 0 && a == 0) {
            break;
        }
        x += d * cos(r * PI);
        y += d * sin(r * PI);
        r -= a;
        if (r >= 360) {
            r -= 360;
        }
        else if (r < 0) {
            r += 360;
        }
    }
    printf("%d\n%d\n", (int)x, (int)y);
    
    return 0;
}

Measured memory_bytes: 1192