akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset> 
#include <cstdio> 
#include <vector>
using namespace std;
int n;
char str[100010];
int main(){
	cin>>str;
	int L=strlen(str);
	int middle=L/2;
	int ans=middle;
	char mch=str[middle];
	if(L&1){
		for(int i=middle;i>=0;i--){
			if(str[i]==mch&&str[L-1-i]==mch){
				ans++;
			}
			else break;
		}
	}
	else {
		middle--;
		for(int i=middle;i>=0;i--){
			if(str[i]==mch&&str[L-1-i]==mch){
				ans++;
			}
			else break;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	string s;
	cin >> s;
	ll n = s.size();

	string t;
	vll v(0);
	for (ll i = 0; i < n; i++) {
		if (s[i] != 'x') {
			t.push_back(s[i]);
			v.push_back(i);
		}
	}

	if (v.empty()) {
		cout << 0 << endl;
		return 0;
	}

	string u = t;
	reverse(all(u));
	if (t != u) {
		cout << -1 << endl;
		return 0;
	}

	t = s.substr(0, v[(v.size() - 1) / 2]);
	u = s.substr(v[v.size() - 1 - (v.size() - 1) / 2] + 1);
	reverse(all(u));

	queue<char> q1, q2;
	for (ll i = 0; i < t.size(); i++) q1.push(t[i]);
	for (ll i = 0; i < u.size(); i++) q2.push(u[i]);

	ll ans = 0;
	while (q1.size() || q2.size()) {
		if (q1.size() && q2.size()) {
			if (q1.front() == q2.front()) {
				q1.pop();
				q2.pop();
			}
			else if (q1.front() == 'x') {
				q1.pop();
				ans++;
			}
			else if (q2.front() == 'x') {
				q2.pop();
				ans++;
			}
		}
		else if (q1.size()) {
			ans += q1.size();
			break;
		}
		else if (q2.size()) {
			ans += q2.size();
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1608
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,x,y; cin>>n>>x>>y;
    vector<int>ans(n+1);
    for(int i=1;i<n;i++) {
        for(int j=i+1;j<=n;j++) {
            int min_dist=min(abs(i-j),abs(x-i)+abs(y-j)+1);
            ans[min_dist]++;
        }
    }
    for(int i=1;i<n;i++) {
        cout<<ans[i]<<endl;
    }
}

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

const int INF = 1000000;
bool cmp0 (pair<int, int> a, pair<int, int> b) {return a.first > b.first; }
bool cmp1 (pair<int, int> a, pair<int, int> b) {return a.second < b.second; }

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> ab(N), cd(N);
    for (int i=0; i<N; ++i) {
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    for (int i=0; i<N; ++i) {
        int c, d;
        cin >> c >> d;
        cd[i] = make_pair(c, d);
    }

    sort(ab.begin(), ab.end(), cmp0);
    sort(cd.begin(), cd.end(), cmp1);

    int ans = 0;
    for (int i=0; i<N; ++i) {
        for (int j=0; j<N; ++j) {
            if (ab[j].first < cd[i].first &&
                ab[j].second < cd[i].second) {
                    ab[j] = make_pair(INF, INF);
                    ++ans;
                    break;
                }
        }
    }

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

Measured memory_bytes: 256
/*
***************************************************************************
 name  : ITP1_02_C.cpp
 title : Sorting Three Numbers
 make  : 2018/08/01 tanabe
***************************************************************************
*/

// Library
#include <iostream> // standard input output object

// Prototype
void Swap(int *x,int *y); // Swap the values of x and y

main(void){
  int a,b,c; // integers

  std::cin >> a >> b >> c; // input "a b c"

  if(a > b){
    Swap(&a,&b); // swap a and b
  }
  if(a > c){
    Swap(&a,&c); // swap a and c
  }
  if(b > c){
    Swap(&b,&c); // swap b and c
  }

  std::cout << a << " " << b << " " << c << std::endl; // output "a b c"

}

// +----------------------------------+
// | name       : Swap                |
// | obtain     : int *x,int *y       |
// | return     : none                |
// | processing : calculate time      |
// +----------------------------------+
void Swap(int *x,int *y){
  int temp; // temporary containers

  // swap
  temp = *x;
  *x = *y;
  *y = temp;

}



Measured memory_bytes: 3108
n=int(input())
l=list(map(int,input().split()))

ave=sum(l)/len(l)
if ave==int(ave):
 a=int(ave)
 b=int(ave)
else:
 a=int(ave)
 b=int(ave)+1

cnt1,cnt2=0,0
for i in l:
 cnt1+=(a-i)**2
 cnt2+=(b-i)**2
print(min(cnt1,cnt2))

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

int main() {

  int a,b,c,d;
  string s;
  cin>>s;
  
  a = s.size()-2;
  
  cout<<s.at(0)<<a<<s.at(s.size()-1)<<endl;
 
  
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    a76(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a76(args: Array<String>) {
    if (args.size != 2) {
        throw IllegalArgumentException()
    }
    val (current, wish) = args.map { it.toInt() }
    println(current + (wish - current) * 2)
}

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

int main()
{
	int ans[55], N,k = 0;

	cin >> N;

	for (int i = 11; i < 55555; i+=5) {
		int c = 1;
		for (int j = 2; j < i; j++) {
			if (i%j == 0) {
				c = 0;
				break;
			}
		}
		if (c) {
			ans[k] = i;
			k++;
			if (k == N)break;
		}
	}

	for (int i = 0; i < N; i++) {
		cout << ans[i];
		if (i != N - 1)cout << " ";
	}

	return 0;
}

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

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

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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//____________________


int32_t main()
{ 
  io;
 
  
  cout<<fixed<<setprecision(12);
  
  string name;
  double val;
  map<string,double> gift;
  int n;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>val>>name;
    gift[name]+=val;
  }
  double tot=0.0;

  tot=gift["JPY"];
  tot+=(gift["BTC"])*(380000.00);
  cout<<tot;
 return 0;
}

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

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  if (a > b) {
    std::swap(a,b);
  }
  if (b > c) {
    std::swap(b,c);
  }
  if (a > b) {
    std::swap(a,b);
  }
  std::cout << a << " " << b << " "<< c << std::endl;
  return 0;
}



Measured memory_bytes: 3080
l,r=map(int,input().split())
mod=2019
if r-l>=2019:
    print(0)
    exit()
else:
    x=[]
    for i in range(l,r):
        for j in range(i+1,r+1):
            x.append(((i%mod)*(j%mod))%mod)
    print(min(x))


Measured memory_bytes: 108812
L,R=map(int,input().split())
ans=2020
if R-L>=4037:
    print(0)
else:
    for i in range(L,R):
        for j in range(i+1,R+1):
            temp=((i%2019)*(j%2019))%2019
            if ans>temp:
                ans=temp
    print(ans)


Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
int n,x,ans;
vector<int>v;
int main()
{
	scanf("%d",&n);
	n*=2;
	for(int i=1;i<=n;i++)scanf("%d",&x),v.push_back(x);
	sort(v.begin(),v.end());
	for(int i=0;i<n;i+=2)ans+=v[i];
	printf("%d",ans);
}


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

int main() {
  int n;
  ll ans = 0;
  cin >> n;
  vector<ll>s(n);
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    ans -= b;
    s[i] = b+a;
  }
  sort(s.begin(),s.end());
  reverse(s.begin(),s.end());
  for(int i = 0;i < n;i += 2) ans += s[i];
  cout << ans << endl;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  ll W,H,N;
  cin >> W >> H >> N;
  vector<int> x(N),y(N),a(N);
  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i] >> a[i];
  }
  int x_1=0,x_2=W,y_1=0,y_2=H;
  for(int i=0;i<N;i++){
    if(a[i]==1){
      x_1=max(x[i],x_1);
    }
    else if(a[i]==2){
      x_2=min(x[i],x_2);
    }
    else if(a[i]==3){
      y_1=max(y_1,y[i]);
    }
    else{
      y_2=min(y_2,y[i]);
    }
  }
  cout << max(0,x_2-x_1)*max(0,y_2-y_1) << endl;
}

Measured memory_bytes: 256
def solve():
    n = [int(i) for i in input().split()][:3]


    c1 = n.count(n[0])
    c2 = n.count(n[1])
    c3 = n.count(n[2])


    if(c1 == 3):
        print(1)
    elif(c1 == c2 == c3 == 1):
        print(3)
    else:
        print(2)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10**6)

n = int(input())

readline = sys.stdin.readline

d = {}

for _ in range(n):
    a,b = [int(i) for i in readline().split()]
    d[b] = d.get(b, 0) + a

d_sorted = sorted(d.items(), key=lambda x:x[0])

s = 0
for t, w in d_sorted:
    s += w
    if s > t:
        print('No')
        break
else:
    print('Yes')

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

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int[] p = new int[5];
		int min = 4000;

		Scanner sc = new Scanner(System.in);		
		for(int i = 0; i< 5;i++){
			p[i] = sc.nextInt();
		}
		for(int i = 0;i <3 ;i++){
			int sum = 0;
			for(int k=3;k<5;k++){
				sum = p[i]+p[k]-50;
				if(min > sum){
					min = sum;
				}
			}
		}
		System.out.println(min);
	}

}

Measured memory_bytes: 17360
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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 ll INF = 1e18;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i];
    rep(i, n) cin >> y[i];

    int a = -1, b = -1, m = 0;
    vector<int> per;
    rep(i, n) per.push_back(i+1);
    do {
        m++;
        bool flag = true;
        rep(i, n) flag &= (per[i] == x[i]);
        if(flag) a = m;

        flag = true;
        rep(i, n) flag &= (per[i] == y[i]);
        if(flag) b = m;
    } while(next_permutation(all(per)));

    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define js ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
typedef long long ll;
char s[200005];
int main(){
	ll sum=0;
	scanf("%s",s);
	for(int i=0;i<strlen(s);i++){
		sum+=(s[i]-'0')%9;
	}
	if(sum%9==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n; cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)cin>>a[i];
    int l[n+2],r[n+2];
    l[0]=r[n+1]=0;
    for(int i=1;i<=n;i++){
        l[i]=__gcd(l[i-1],a[i]);
    }
    for(int i=n;i>=1;i--){
        r[i]=__gcd(r[i+1],a[i]);
    }
    int ans=-1;
    for(int i=1;i<=n;i++){
        ans=max(ans,__gcd(l[i-1],r[i+1]));
    }
    cout<<ans<<endl;
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;

#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 4000000000; //4*10^9;
constexpr auto MOD = 1000000007; //10^9+7;

int main()
{
	set<int> s= { 1,2,3 };
	int a, b;
	cin >> a >> b;

	s.erase(a);
	s.erase(b);

	cout << *s.lower_bound(1) << endl;

}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define size_of(a) (int)a.size()

typedef pair< int, int > Seg;

int N, n;
map< int, int > ftoi, itof;
vector< Seg > segs, fseg[10010];

void _write_() {
	int l, S; cin >> l >> S;
	ftoi[l] = n;
	itof[n] = l;
	
	vector< Seg > new_segs;	
	
	for_(i,0,size_of(segs)) {
		if (S) {
			int w = segs[i].second - segs[i].first;
		
			if (w <= S) {
				S -= w;
				fseg[n].push_back(segs[i]);
			} else {
				fseg[n].push_back(Seg(segs[i].first, segs[i].first + S));
				new_segs.push_back(Seg(segs[i].first + S, segs[i].second));
				S = 0;
			}
		} else {
			new_segs.push_back(segs[i]);
		}
	}
	
	segs = new_segs;
	
	++n;
}

void _delete_() {
	int l; cin >> l;
	int f = ftoi[l];
	
	for_(i,0,size_of(fseg[f])) segs.push_back(fseg[f][i]);
	
	fseg[f].clear();
	
	sort(segs.begin(), segs.end());
	
	int s = segs[0].first, t = segs[0].second;
	vector< Seg > new_segs;
	
	for_(i,1,size_of(segs)) {
		if (segs[i].first == t) {
			t = segs[i].second;
		} else {
			new_segs.push_back(Seg(s, t));
			s = segs[i].first;
			t = segs[i].second;
		}
	}
	new_segs.push_back(Seg(s, t));
	
	segs = new_segs;
}

void _read_() {
	int p; cin >> p;
	
	for_(i,0,n) {
		for_(j,0,size_of(fseg[i])) {
			if (fseg[i][j].first <= p && p < fseg[i][j].second) {
				cout << itof[i] << endl;
				return;
			}
		}
	}
	
	cout << -1 << endl;
}

int main() {	
	while (cin >> N, N) {
		n = 0;
		ftoi.clear();
		itof.clear();
		
		segs.clear();
		segs.push_back(Seg(0, (int)1e9 + 1));
		
		for_(i,0,N) fseg[i].clear();
		
		for_(i,0,N) {
			char c; cin >> c;
			switch (c) {
			case 'W':
				_write_();
				break;
			case 'D':
				_delete_();
				break;
			case 'R':
				_read_();
				break;
			}
		}
		
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 19020
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

bool by_b (pair<ll, ll> a, pair<ll, ll> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

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

    ll N;
    cin >> N;
    vector<pair<ll, ll>> red(N), blue(N);
    Rep (i, N) {
        cin >> red[i].first >> red[i].second;
    }
    Rep (i, N) {
        cin >> blue[i].first >> blue[i].second;
    }

    sort(blue.begin(), blue.end());
    sort(red.begin(), red.end());

    vector<bool> redused(N, false);
    ll ans = 0;
    Rep (i, N) {
        ll x = blue[i].first;
        ll y = blue[i].second;
        ll nakayoshi = -1;
        ll nx = -1, ny = -1;
        Rep (j, N) {
            if (!redused[j] && red[j].first < x && red[j].second < y) {
                if (ny < red[j].second) {
                    nakayoshi = j;
                    ny = red[j].second;
                }
            }
        }

        if (0 <= nakayoshi) redused[nakayoshi] = true;
    }

    for (auto e : redused) if (e) ans++;

    cout << ans << "\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

string s[50];
int d[50][50];
int h, w;

bool good(int x, int y)
{
    return x >= 0 && y >= 0 && x < h && y < w;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    int b = 0;
    for (int i = 0; i < h; ++i)
    {
        cin >> s[i];
        for (int j = 0; j < w; ++j)
            b += (s[i][j] == '#');
    }
    memset(d, -1, sizeof d);
    queue<pair<int, int>> q;
    q.emplace(0, 0);
    d[0][0] = 0;
    while (!q.empty())
    {
        int a, b;
        tie(a, b) = q.front();
        q.pop();
        int dx[4] = {0, 0, -1, 1};
        int dy[4] = {1, -1, 0, 0};
        for (int k = 0; k < 4; ++k)
        {
            int x = a + dx[k];
            int y = b + dy[k];
            if (good(x, y) && d[x][y] == -1 && s[x][y] == '.')
            {
                d[x][y] = d[a][b] + 1;
                q.emplace(x, y);
            }
        }
    }
    if (d[h - 1][w - 1] == -1)
        cout << -1;
    else
        cout << w * h - b - d[h - 1][w - 1] - 1;
}


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

#define vi vector<int>
using namespace std;

int cnt = 0;

vi helper;
void mergeSort(vi &a,int left,int right){
    if(left < right){
        int mid = (left + right) / 2;
        mergeSort(a,left,mid);
        mergeSort(a,mid+1,right);

        for (int i = left; i <= right; ++i) {
            helper[i] = a[i];
        }
        int i = left;
        int j = mid + 1;
        for (int k = i; k <= right; ++k){
            cnt++;
            if ( i > mid || j <= right && helper[i] > helper[j]){
                a[k] = helper[j++];
            }else {
                a[k] = helper[i++];
            }
        }
        //???????????§??????
    }
}

int main(){
    //freopen("in", "r", stdin);
    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    helper.resize(n);
    mergeSort(a,0,n-1);

    for (int i = 0; i < n; ++i) {
        if(i) cout << " ";
        cout << a[i];
    }
    cout << endl << cnt << endl;
    return 0;
}

Measured memory_bytes: 6704
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int n, p[22], c = 0;

  std::cin >> n;

  for (int i = 0; i < n; i ++)
    std::cin >> p[i];

  for (int j = 1; j < n - 1; j ++) {
    int i = j - 1, k = j + 1;
    
    if ((p[i] <= p[j] && p[k] >= p[j]) ||
        (p[i] >= p[j] && p[k] <= p[j]))

      c ++;
  }
  
  std::cout << c << std::endl;
  
  return 0;
}


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

int t[100010];
int a[100010];
int ans, sum;
int x;
char c[2];

int main()
{
  int n, m;
  scanf("%d%d", &n, &m);
  for(int i = 1; i <= m; i++)
  {
    scanf("%d%s", &x, &c);
    if(c[0] == 'A') t[x] = 1;
    else if(t[x] != 1) a[x]++;
  }
  for(int i = 1; i <= n; i++)
  {
    ans += t[i];
    if(t[i] == 1) sum += a[i];
  }
  printf("%d %d", ans, sum);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define ALL(a) (a).begin(), (a).end()

signed main(){
  vi a;
  a.resize(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(ALL(a));
  cout << 10*a[2]+a[1]+a[0] << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (true) {
            int[] xs = new int[]{input.nextInt(), input.nextInt()};
            if (xs[0] == 0 && xs [1] == 0) break;
            if (xs[0] > xs[1]) {
                int temp = xs[1];
                xs[1] = xs[0];
                xs[0] = temp;
            }
            System.out.println(String.format("%d %d", xs[0], xs[1]));
        }
    }
}

Measured memory_bytes: 33072
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        List<Integer> l = Arrays.asList(1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51);

        System.out.println(l.get(T-1));
    }

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
const int MAXn = 2e3 + 10, MOD = 1e9 + 7;

long long dp[MAXn][MAXn], ar[MAXn], ar2[MAXn], n, m, ps[MAXn][MAXn];

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> ar[i];
	for (int i = 0; i < m; i++)
		cin >> ar2[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			if (ar[i] == ar2[j]) {
				if (i && j)
					dp[i][j] = ps[i-1][j-1] + 1;
				else 
					dp[i][j] = 1;
			}
			if (i && j)
				ps[i][j] = (ps[i-1][j] + ps[i][j-1] - ps[i-1][j-1] + dp[i][j] + MOD) % MOD;
			else if (i) {
				ps[i][j] = (ps[i-1][j] + dp[i][j]) % MOD;
			}
			else if (j)
				ps[i][j] = (ps[i][j-1] + dp[i][j]) % MOD;
			else
				ps[i][j] = dp[i][j];
		}
	//cout << ps[1][0];
	cout << (ps[n-1][m-1] + 1) % MOD;
}


Measured memory_bytes: 63104
#include <bits/stdc++.h>
using namespace std;
// clang-format off

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
// clang-format on
const long long MOD = 1000000007;

void solve(long long N, long long K) {
  // solver code

  LL res = 0;

  for (int i = K; i <= N + 1; i++) {
    res += i * (N - i + 1) + 1;
    res %= MOD;
  }

  cout << res << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long K;
  scanf("%lld", &K);
  solve(N, K);
  return 0;
}


Measured memory_bytes: 3764
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    A =[]
    B =[]
    for i in range(N):
        A.append(list(_ for _ in input()))
    for i in range(M):
        B.append(list(_ for _ in input()))

    for i in range(N-M+1):
        for j in range(N-M+1):
            # check
            flag = True
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        flag = False
                        break
            if(flag):
                ans = 'Yes'
                print(ans)
                exit()
            else:
                ans = 'No'


    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

class Cell{
	long a;
	long b;
	this(long a, long b){
		this.a = a, this.b = b;
		}
	}


void main(){
	long h, w, n;
	{
		long[] tmp = readln.chomp.split.map!(to!long).array;
		h = tmp[0], w = tmp[1], n = tmp[2];
		}
	
	Cell[] cells;
	foreach(i; 0 .. n){
		long[] tmp = readln.chomp.split.map!(to!long).array;
		cells ~= new Cell(tmp[0], tmp[1]);
		}
	
	int[string] us;
	
	void add(long a, long b){
		if(a <= 1) return;
		if(b <= 1) return;
		if(a >= h) return;
		if(b >= w) return;
		us[a.to!string ~ "/" ~ b.to!string] += 1;
		}
	
	foreach(c; cells){
		add(c.a, c.b);
		add(c.a - 1, c.b);
		add(c.a + 1, c.b);
		add(c.a, c.b - 1);
		add(c.a - 1, c.b - 1);
		add(c.a + 1, c.b - 1);
		add(c.a, c.b + 1);
		add(c.a - 1, c.b + 1);
		add(c.a + 1, c.b + 1);
		}
	
	int[10] count;
	
	foreach(k; us.keys){
		count[us[k]] += 1;
		}
	
	
	BigInt count0 = BigInt(h - 2) * BigInt(w - 2);
	foreach(c; count[1 .. $]) count0 -= c;
	
	count0.writeln;
	foreach(c; count[1 .. $]) c.writeln;
	
	}

Measured memory_bytes: 126844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,k,x,y,cnt[2][1010][1010]={},d[2][1010][1010]={},s[2][1010][1010]={},ans=0;
  char c;
  cin>>n>>k;
  fr(i,n){
    cin>>x>>y>>c;
    x%=2*k;
    y%=2*k;
    cnt[(c=='B')^(x>=k)^(y>=k)][x%k][y%k]++;
  }
  fr(l,2) fr(i,k) Fr(j,k) d[l][i][j]=d[l][i][j-1]+cnt[l][i][j-1];
  fr(l,2) Fr(i,k) Fr(j,k) s[l][i][j]=s[l][i-1][j]+d[l][i-1][j];
  fr(i,k+1) fr(j,k+1) ans=max(ans,max(s[1][k][k]-s[1][i][k]-s[1][k][j]+2*s[1][i][j]+s[0][i][k]+s[0][k][j]-2*s[0][i][j],n-(s[1][k][k]-s[1][i][k]-s[1][k][j]+2*s[1][i][j]+s[0][i][k]+s[0][k][j]-2*s[0][i][j])));
  cout<<ans<<endl;
}

Measured memory_bytes: 48128
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

int main() {
  int K;
  string S;
  cin >> K;
  cin >> S;
  int i = 0;
  for (;i < S.size() && i < K;i ++) {
    cout << S[i];
  }
  if (S.size() > K) {
    cout << "...";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1
#define true 1
#define false 0

int row[N], col[N], dpos[N * 2 - 1], dneg[N * 2 - 1];
int X[N][N];

void printBoard(){
  int i, j;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      if(X[i][j]){
	if(row[i] != j) return;
      }
    }
  }
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      printf((row[i] == j) ? "Q" : ".");
    }
    printf("\n");
  }
  
}

void recursive(int i){
  int j;
  
  if(i == N){
    printBoard();
    return;
  }

  for(j = 0; j < N; j++){
    if(col[j] == NOT_FREE || dpos[i + j] == NOT_FREE || dneg[i - j + N - 1] == NOT_FREE) continue;
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
    recursive(i + 1);
    row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
  }
  
}

int main(){
  int i, j;
  int k, r, c;

  for(i = 0; i < N; i++) row[i] = col[i] = FREE;
  for(i = 0; i < 2 * N - 1; i++) dpos[i] = dneg[i] = FREE;

  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      X[i][j] = false;
    }
  }
  scanf("%d", &k);
  for(i = 0; i < k; i++){
  scanf("%d %d", &r, &c);
  X[r][c] = true;
  }

  recursive(0);
  
  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
typedef double D;
typedef complex<D> P;
const D EPS = 1e-9;
#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)
D dot(P a, P b) {return (conj(a)*b).X; }
D cross(P a, P b) {  return (conj(a)*b).Y;}
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;
  if (cross(b,c) < -EPS) return -1;
  if (dot(b,c)   < -EPS) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}

bool isecSS(P a1, P a2, P b1, P b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
         ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}
int dp[200][200],n,x,y;
vector<P>v,car;
vector<int>vy,vx;
void input(){
  memset(dp,0,sizeof(dp));
  v.clear();
  vx.clear();
  vy.clear();
  car.clear();
  r(i,n){
    cin>>x>>y;
    x+=20001;
    y+=20001;
    v.push_back(P(x,y));
    vx.push_back(x);
    vy.push_back(y);
  }
  r(i,4){
    cin>>x>>y;
    x+=20001;
    y+=20001;
    car.push_back(P(x,y));
    vx.push_back(x);
    vy.push_back(y);
  }
}
void zaatsu(){
  sort(vx.begin(),vx.end());
  vx.erase(unique(vx.begin(),vx.end()),vx.end());
  sort(vy.begin(),vy.end());
  vy.erase(unique(vy.begin(),vy.end()),vy.end());
  r(i,vy.size()-1){
    r(j,vx.size()-1){
      dp[i][j]=(vy[i+1]-vy[i])*(vx[j+1]-vx[j]);
    }
  }
}
int calc(){
  int ans=0;
  r(i,vy.size()-1){
    r(j,vx.size()-1){
      P st=P(0.5+vx[j],0.5+vy[i]);
      P go=P(0.5+vx[j],-100);
      int res=0,f=0;
      r(k,v.size()){
        if(isecSS(st,go,v[k],v[(k+1)%v.size()]))res++;
      }
      r(k,car.size()){
        if(isecSS(st,go,car[k],car[(k+1)%car.size()]))f++;
      }
      if(res%2&&f%2==0)ans+=dp[i][j];
    }
  }
  return ans;
}
int main(){
  while(cin>>n,n){
    input();
    zaatsu();
    cout<<calc()<<endl;
  }
}

Measured memory_bytes: 3300
// AOJ 2082: Goofy Converter
// 2017.11.7 bal4u@uu

#include <stdio.h>

int a[1002], n, m;
char ans[1020], *p;

int bin2sz(int k, int goal)
{
	int i, c = 0;
	i = m; while (i--) {
		if (k & 1) ans[i] = '1', c++;
		else       ans[i] = '0';
		if (c > goal) return 0;
		k >>= 1;
	}
	return c == goal;
}

int check()
{
	int i, j, c;

	for (j = m, i = 1; i < n; i++, j++) {
		if (a[i] == a[i-1]) ans[j] = ans[i-1];
		else {
			ans[j] = '0'+ ('1' - ans[i-1]);
			if (ans[i-1] == '1') c = a[i-1]-1;
			else                 c = a[i-1]+1;
			if (c != a[i]) return 0;
		}
	}
	return 1;
}

int main()
{
	int i, lim;

	while (scanf("%d%d", &n, &m) && n > 0) {
		for (i = 0; i < n; i++) scanf("%d", a+i);
		lim = 1 << m;
		for (i = 0; i < lim; i++) {
			if (bin2sz(i, a[0]) && check()) break;
		}
		if (i == lim) puts("Goofy");
		else ans[n+m-1] = 0, puts(ans);
	}
	return 0;
}

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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a<c&&d<b) print(d-c);
  else if(c<b&&a<=c) print(b-c);
  else if(c<a&&b<d) print(b-a);
  else if(a<d&&c<=a) print(d-a);
  else print(0);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

vector<vector<int>> graph(200010, vector<int>());
vector<int> col(200010, -1);

void dfs(int n, int p, int c) {
	col[n] = c;
	for (int i : graph[n]) {
		if (i == p) continue;
		dfs(i, n, (c + 1) % 2);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<int> a(n - 1), b(n - 1);
	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		graph[a[i]].pb(b[i]);
		graph[b[i]].pb(a[i]);
	}
	dfs(0, -1, 0);
	int cnt = 0;
	rep(i, n) if (col[i]) cnt++;
	vector<int> ans(n);
	vector<bool> use(n);
	if (cnt <= n / 3) {
		int c = 3;
		rep(i, n) {
			if (col[i]) {
				ans[i] = c;
				use[c - 1] = true;
				c += 3;
			}
		}
		int x = 1;
		rep(i, n) {
			if (!col[i]) {
				while (use[x - 1]) {
					x++;
				}
				ans[i] = x; x++;
			}
		}
	}
	else if (n - cnt <= n / 3) {
		int c = 3;
		rep(i, n) {
			if (!col[i]) {
				ans[i] = c;
				use[c - 1] = true;
				c += 3;
			}
		}
		int x = 1;
		rep(i, n) {
			if (col[i]) {
				while (use[x - 1]) {
					x++;
				}
				ans[i] = x; x++;
			}
		}
	}
	else {
		int c1 = 1, c2 = 2;
		for (int i = 0; i < n; i++) {
			if (col[i] == 0 && c1 <= n) {
				ans[i] = c1;
				use[c1 - 1] = true;
				c1 += 3;
			}
			else if (col[i] == 1 && c2 <= n) {
				ans[i] = c2;
				use[c2 - 1] = true;
				c2 += 3;
			}
		}
		int c3 = 1;
		for (int i = 0; i < n; i++) {
			if (ans[i] == 0) {
				while (use[c3 - 1]) {
					c3++;
				}
				ans[i] = c3; c3++;
			}
		}
	}
	for (int i : ans) cout << i << ' ';
	cout << endl;
}


Measured memory_bytes: 23040
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFerrisWheel solver = new AFerrisWheel();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFerrisWheel {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a < 6) {
                out.println(0);
            } else if (a < 13) {
                out.println(b / 2);
            } else {
                out.println(b);
            }
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

        public void close() {
        }

    }
}



Measured memory_bytes: 21332
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

ll p; // p must be a prime number.
vector<int> a;

void input(){
    cin >> p;
    a.resize(p);
    for (int i = 0; i < p; ++i)
        cin >> a[i];
}

// 多項式
struct polynomial{
    int d;
    vector<ll> c;
    polynomial(int d) : d(d), c(d, 0LL) {}
    void show(){
        for (auto ci : c) cout << ci << " ";
        cout << endl;
    }
};

// aのb乗をmod pで求める
ll modpow(ll a, ll b){
    if (b == 0) return 1;
    ll tmp = modpow(a, b / 2);
    if (b % 2)
        return tmp * tmp % p * a % p;
    return tmp * tmp % p;
}

// k!をmod pで求める、sgnを非0に設定すると逆元を返す
ll fact(ll k, int sgn = 0) {
	static vector<ll> fac(2, 1LL);
	static vector<ll> inv(2, 1LL);
	static vector<ll> finv(2, 1LL);
	static ll nx = 2LL;
	while (nx <= k) {
		fac.push_back(fac[nx - 1] * nx % p);
		inv.push_back(p - inv[p % nx] * (p / nx) % p);
		finv.push_back(finv[nx - 1] * inv[nx] % p);
		++nx;
	}
	if (sgn == 0) return fac[k];
	return finv[k];
}

// 二項係数をmod pで求める
ll comb(ll a, ll b) {
	if (b < 0 || b > a) return 0;
	return fact(a) * fact(b, 1) % p * fact(a - b, 1) % p;
}

// x = i (mod p)のときのみ1、そうでないとき0となる多項式
polynomial delta(int i){
    polynomial res(p);
    ll power = 1LL;
    for (int k = p - 1; k >= 0; --k){
        ll tmp = power * comb(p - 1, k) % p;
        res.c[k] = (-tmp + p) % p;
        power = (-i + p) % p * power % p;
    }
    res.c[0] = (res.c[0] + 1) % p;
    return res;
}

// 2つの多項式を足す
void add(polynomial& f1, polynomial& f2){
    int d = max(f1.d, f2.d);
    f1.c.resize(d);
    for (int i = 0; i < d; ++i){
        if (f2.d > i)
            f1.c[i] = (f1.c[i] + f2.c[i]) % p;
    }
}

// 問題を解く
polynomial solve(){
    polynomial res(p);
    for (int i = 0; i < p; ++i){
        if (a[i]){
            polynomial tmp = delta(i);
            add(res, tmp);
        }
    }
    return res;
}

int main(){
    input();
    solve().show();
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>

int main() {
	std::string str; std::cin >> str;
	std::cout << str.substr(0, 3) << std::endl;
}

Measured memory_bytes: 3628
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    cnt=0
    a=0
    b=0
    A="A"
    B="B"
    ab=0
                
    
    for i in range(N):
        s=input()
        cnt+=s.count("AB")
        if s[0]==B and s[-1]==A:
            ab+=1
        elif s[0]==B:
            b+=1
        elif s[-1]==A:
            a+=1
            
    if a==0 and b==0:
        cnt+=ab-1
        if ab==0:
            cnt+=1
    else:
        cnt+=ab
    ans=cnt+min(a,b)
    print(ans)

main()


Measured memory_bytes: 74292
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    vector<string> vec;
    string tmp;
    for(int i=0;i<3;i++){
        cin >> tmp;
        vec.push_back(tmp);
    }

    for(int i=0;i<3;i++)
        reverse(vec[i].begin(), vec[i].end());
    char next = 'a';
    for(;;){
        if(next == 'a'){
            if( !vec[0].empty() ){
                next = vec[0].back();
                vec[0].pop_back();
            }else{
                cout << "A" << endl;
                return 0;
            }
        }else if(next == 'b'){
            if( !vec[1].empty() ){
                next = vec[1].back();
                vec[1].pop_back();
            }else{
                cout << "B" << endl;
                return 0;
            }
        }else{
            if( !vec[2].empty() ){
                next = vec[2].back();
                vec[2].pop_back();
            }else{
                cout << "C" << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int dp[51];

int main(){
    int n;
    int store[6][2] = {
        {2,380},
        {3,550},
        {5,850},
        {10,1520},
        {12,1870},
        {15,2244}
    };
    while(cin >> n, n){
        rep(i, 51){
            dp[i] = 2 << 24;
        }
        dp[0] = 0;
        n /= 100;
        rep(i, n + 1){
            rep(j,6){
                if(i >= store[j][0]){
                    dp[i] = min(dp[i], dp[i - store[j][0]] + store[j][1]);
                }
            }
        }
        cout << dp[n] << endl;
    }
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

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

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
	ll a;
	cin >> a;

	ll x = a * 800;
	ll y = a / 15 * 200;

	println(x - y);
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  int ans=0;
  for(int i=1;i<=N;i++){
    int sum=0;
    for(int j=1;j<=i;j++){
      if(i%j==0)sum++;
    }
    if(i%2&&sum==8)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(void) {
	ll n;
	cin >> n;
	for (ll i = pow(n, 0.5); i >= 2; i--) {
		if ((ll)n % i == 0) {
			cout << (i - 1) + ((ll)n / i - 1) << endl;
			return 0;
		}
	}
	cout << n - 1 << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>

using namespace std;

int main(){

	int n;
	cin>>n;
	for(int i = 0; i < n; i++){
		int from,to;
		cin>>from>>to;
		// ¶ûüÉV~[V
		int angle=1;
		int c=from;
		vector<int> ph;
		ph.push_back(c);
		while(1){
			if(angle==0&&c==5){
				c++;
			}
			else if(angle==1&&c==5){
				c--;
			}
			else if(c>=6&&c<=9){
				c++;
				if(c==10){
					c=5;
					angle=1;
				}
			}
			else if(angle==0&&c>=1&&c<=4){
				c++;
			}
			else if(angle==1&&c>=1&&c<=4){
				c--;
			}
			else if(c==0){
				c++;
				angle=0;
			}
			ph.push_back(c);
			if(c==to)
				break;
		}
		c=from;
		angle=0;
		vector<int>ph2;
		ph2.push_back(c);
		while(1){
			if(angle==0&&c==5){
				c++;
			}
			else if(angle==1&&c==5){
				c--;
			}
			else if(c>=6&&c<=9){
				c++;
				if(c==10){
					c=5;
					angle=1;
				}
			}
			else if(angle==0&&c>=1&&c<=4){
				c++;
			}
			else if(angle==1&&c>=1&&c<=4){
				c--;
			}
			else if(c==0){
				c++;
				angle=0;
			}
			ph2.push_back(c);
			if(c==to)
				break;
		}
		if(ph.size()<ph2.size()){
			for(int j = 0; j < ph.size(); j++){
				cout<<ph[j];
				if(j!=ph.size()-1){
					cout<<" ";
				}
				else
					cout<<endl;
			}
		}
		else{
			for(int j = 0; j < ph2.size(); j++){
				cout<<ph2[j];
				if(j!=ph2.size()-1){
					cout<<" ";
				}
				else
					cout<<endl;
			}
		}

	}

	return 0;
}

Measured memory_bytes: 0