akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);


int main()
{
    int a,b;
    cin >> a >> b;
    if(a>=10 || b>=10)
	{
		cout << -1 ;
		
	}
	else
	{
		cout << a*b ;
	}
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF (1e9+7)

using namespace std;

typedef pair<int, int> pii;

struct edge{
  int l;
  bool xaxis;
  edge(const pii &fr,const pii &to){
    if(fr.first == to.first){
      l = to.second - fr.second;
      xaxis = false;
    } else {
      l = to.first - fr.first;
      xaxis = true;
    }
  }
  edge() : l(0), xaxis(false) {}
};

vector<pii> vs(50);
vector<pii> revvs(50);
vector<pii> tvs(50);
vector<edge> forw(10);
vector<edge> rev(10);
vector<edge> tmpl(10);
vector<edge> target(10);

int main(){
  int n;
  while(cin >> n and n){
    int m;
    cin >> m;
    REP(i, m) {
      int tmpx, tmpy; cin >> tmpx >> tmpy;
      vs[i] = make_pair(tmpx, tmpy);
      revvs[m-1-i] = make_pair(tmpx, tmpy);
    }
    REP(i, m-1){
      forw[i] = edge(vs[i], vs[i+1]);
      rev[i] = edge(revvs[i], revvs[i+1]);
    }
    for(int count = 1; count < n+1; count++){
      int mm; cin >> mm;
      REP(i, mm) {
        int tmpx, tmpy; cin >> tmpx >> tmpy;
        tvs[i] = make_pair(tmpx, tmpy);
      }
      if(m != mm) continue;
      REP(i, m-1) target[i] = edge(tvs[i], tvs[i+1]);
      for(int kind = 0; kind < 2; kind++){
        bool match = true;
        if(kind) tmpl = rev;
        else tmpl = forw;
        if(abs(tmpl[0].l) != abs(target[0].l)) continue;
        if(tmpl[0].xaxis == target[0].xaxis){
          bool flag = (tmpl[0].l == target[0].l);
          for(int i=1; i<m-1; i++)
            if(tmpl[i].l != ((flag ? 1 : -1) * target[i].l)) match = false;
          if(match) { cout << count << endl; break;}
        } else {
          bool flag = (tmpl[0].l == target[0].l);
          for(int i=1; i<m-1; i++){
            if(i%2) {
              if(tmpl[i].l != ((flag ? -1 : 1) * target[i].l)) match = false;
            } else if(tmpl[i].l != ((flag ? 1 : -1) * target[i].l)) match = false;
          }
          if(match) { cout << count << endl; break; }
        }
      }
    }
    cout << "+++++" << endl;
  }
  return 0;
}

Measured memory_bytes: 2968
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ll 				long long
#define int             long long int
#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define modp            998244353
#define inf             (ll)1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO           	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl 			'\n'
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void solve()
{
	int n;
	cin >> n;
	int x[n], y[n];
	for(int i = 0; i < n; i++)
		cin >> x[i] >> y[i];
	int minp = INT_MAX, maxp = INT_MIN;
	int minn = INT_MAX, maxn = INT_MIN;
	for(int i = 0; i < n; i++)
	{
		minp = min(minp, x[i]+y[i]);
		maxp = max(maxp, x[i]+y[i]);
		minn = min(minn, x[i]-y[i]);
		maxn = max(maxn, x[i]-y[i]);
	}
	cout << max(abs(minp-maxp), abs(minn-maxn));
}
 
int32_t main()
{
	FIO
    // w(t)
    {
    	solve();
    }
    return 0;
}
	

	

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int n;
  cin>>n;
  int a[n];
  for(int i=0; i<n; ++i)
    cin>>a[i];
  int dp[n+1]={};
  dp[1]=fabs(a[1]-a[0]);
  for(int i=2; i<n; ++i)
  {
    dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
  }
  cout<<dp[n-1];
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];
			var M = inputArray[1];

			var voteArray = retreiveLongArray();

			var sum = voteArray.Sum();
			//これ以上の得票数の商品が人気商品として選べる
			var limit = Math.Ceiling(sum / (double)(4 * M));

			var popolarCount = voteArray.Where(x => x >= limit).Count();

			var ans = M <= popolarCount? "Yes":"No";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 13524
n = int(input())
s = input().rstrip()

cs = 'SW'
for ss in [[0, 0], [0, 1], [1, 0], [1, 1]]:
    for i in range(1, n + 1):
        if (ss[i % n] == 0 and s[i % n] == 'o') or (ss[i % n] == 1
                                                    and s[i % n] == 'x'):
            ss.append(ss[i - 1])
        else:
            ss.append(1 - ss[i - 1])
    if ss[-2] == ss[0] and ss[-1] == ss[1]:
        res = ''.join([cs[i] for i in ss[:-2]])
        print(res)
        break
else:
    print(-1)

Measured memory_bytes: 7948
#pragma region Macros
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define REV(x) reverse(ALL(x))
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define SP << " " <<
#define INF2 1000000000000000037
#define INF  1000000007
#define lwb(x,n) distance(x.begin(),lower_bound(ALL(x),(n)))
#define upb(x,n) distance(x.begin(),upper_bound(ALL(x),(n)))
#define fora(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#ifdef _MY_DEBUG
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define de(...) CHOOSE((__VA_ARGS__,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define de(...)
#endif
using namespace std;
using ll = long long;
using ld = long double;
template<class T = ll> using v = vector<T>;
template<class T = ll> using vv = vector<vector<T>>;
template<class T = ll> using vvv = vector<vector<vector<T>>>;
template<class T> bool maxi(T &a, const T &b){ if(a<b){a=b;return 1;}return 0;}
template<class T> bool mini(T &a, const T &b){ if(b<a){a=b;return 1;}return 0;}
template<class T> ll sumer(const T& a){ return accumulate(ALL(a),0LL); }
template<class T> void UNIQUE(vector<T> &a){ SORT(a);a.erase(unique(ALL(a)),a.end());}
template<class T, class U> ostream &operator<<(ostream &os, const pair<T,U> &pe) { os << pe.first << " " << pe.second; return os;}
template<class T> ostream &operator<<(ostream &os, const v<T> &ve) { rep(i,ve.size()) os<< (i?" ":"")<<ve[i]; return os;}
ll topbit(ll a) { return a==0?-1:63-__builtin_clzll(a);}
ll botbit(ll a) { return a==0?64:__builtin_ctzll(a);}
ll popcount(ll a) { return __builtin_popcountll(a);}
#define dame {cout<< retword <<"\n"; return;}
#pragma endregion
//--MODIFS---------------------------------
#pragma region Modifs
#define retword "-1"
#define MOD  1000000007
using P  = pair<ll,ll>;
using TP  = tuple<ll,ll,ll>;
#pragma endregion
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll S,W;
    cin>>S>>W;
    cout<< ( W>=S ? "unsafe" : "safe" )<<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // ll Qkai; cin>>Qkai; rep(QQ,Qkai) Main();
    Main();
}
//-----------------------------------------

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

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if ((a[0] == a[1] && a[1] != a[2]) || (a[1] == a[2] && a[0] != a[2]))	puts("Yes");
	else	puts("No");
	return 0; 
}

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

int main() {
  char c;
  cin >> c;
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = -1;
  
  for (int i = 1;i < 2000;i++){
    int e = i * 8 / 100;
    int t = i / 10;
    if (e == a && t == b){
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
}

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

const int INF = 1e+8;
int G[101][101], d[101][101];

void init(){
	for(int i=0 ; i < 101 ; i++ ){
		for(int j=0 ; j < 101 ; j++ ){
			G[i][j] = (i == j)? 0 : INF;
			d[i][j] = (i == j)? 0 : INF;
		}
	}
}

int main(){
	int n, m, s, g1, g2;
	while( cin >> n >> m >> s >> g1 >> g2 , n ){
		s--; g1--; g2--;
		init();
		for(int i=0 ; i < m ; i++ ){
			int u, v, cost;
			cin >> u >> v >> cost;
			u--; v--;
			G[u][v] = cost;
			d[u][v] = cost;
		}

		for(int k=0 ; k < n ; k++ ){
			for(int i=0 ; i < n ; i++ ){
				for(int j=0 ; j < n ; j++ ){
					d[i][j] = min( d[i][j] , d[i][k] + d[k][j] );
				}
			}
		}
		int ans = INF;
		for(int v=0 ; v < n ; v++ ){
			ans = min( ans , d[s][v] + d[v][g1] + d[v][g2] );
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 944
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

 
struct  UndirectedGraph{
   vector<vector<int>> g;
   vector<int> clr;
   vector<int> dis;
   int V;
 
   UndirectedGraph(int V) : V(V),
   g(vector<vector<int>>(V)),
   clr(vector<int>(V,0))
   {}
 
   //don't add (v,u) after adding (u,v)
   void add_edge(int u,int v){
       g[u].push_back(v);
       g[v].push_back(u);
   }
 
 
   //二部グラフ判定
   bool dfs_nib(int v,int c){
       clr[v]=c;
       for(auto x:g[v]){
           if(clr[x]==c) return false;
           if(clr[x]==0 && !dfs_nib(x,-c) ) return false;
       }
       return true;
   }
   bool isNib(){
       bool ret=true;
       for(int i=0;i<V;i++)if(clr[i]==0){
           if(!dfs_nib(i,1)){
               ret=false;break;
           }
       }
       return ret;
   }
 
   //distance
   void bfs(int st){
       dis=vector<int>(V,INF);
       vector<bool> checked(V,false);
       dis[st]=0;checked[st]=true;
       queue<int> q;
       q.push(st);
       while(!q.empty()){
           auto now=q.front();q.pop();
           for(auto x:g[now]){
               if(checked[x]) continue;
               checked[x]=true;
               dis[x]=dis[now]+1;
               q.push(x);
           }
       }
   }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    if(n==1){
        cout<<"First"<<endl;
        return 0;
    }
    UndirectedGraph g(n);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g.add_edge(u,v);
    }
    g.bfs(0);
    int d=0,a=-1;
    rep(i,n){
        if(chmax(d,g.dis[i])) a=i;
    }
    g.bfs(a);
    int R=0;
    rep(i,n){
        chmax(R,g.dis[i]);
    }
    R++;
    if(R%3==2){
        cout<<"Second"<<endl;
    }
    else{
        cout<<"First"<<endl;
    }
    return 0;
}


Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
#define inf 10e+9
#define ll long long
ll dp[100010];
int weight[101];
int value[101];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int maxVal=0,n,w,ans = 0;
    cin >> n >> w;
    for (int i=1; i <= n; i++) {
        cin >> weight[i] >> value[i];
        maxVal += value[i];
    }
    fill_n(dp, maxVal+1, inf);
    dp[0] = 0;
    for (int i=1; i <= n; i++) {
        for (int allowedValue = maxVal; allowedValue >= value[i]; allowedValue--) {
            dp[allowedValue] = min(dp[allowedValue], weight[i]+dp[allowedValue-value[i]]);
            if (dp[allowedValue]<=w) ans = max(ans, allowedValue);
        }
    }
    cout << ans << "\n";
    return 0;
}

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

/* -128 ~ 127 */
using i8  = int8_t;
/* 0 ~ 255 */
using u8  = uint8_t;
/* -32,768 ~ 32,767 */
using i16 = int16_t;
/* 0 ~ 65,535 */
using u16 = uint16_t;
/* -2,147,483,648 ~ 2,147,483,647 */
using i32 = int32_t;
/* 0 ~ 4,294,967,295 */
using u32 = uint32_t;
/* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using i64 = int64_t;
/* 0 ~ 18,446,744,073,709,551,615 */
using u64 = uint64_t;
/* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f32 = float;
/* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f64 = double;
using f80 = __float80;

template <class T>
using Vec = vector<T>;

template <typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

/* 定数 */
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define fn auto
#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) // 最大公約数
#define LCM(a, b) a / __gcd(a, b) * b // 最小公倍数

fn Main() {
    i32 K;
    cin >> K;
    u64 sum = 0;
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            for (int k = 1; k <= K; k++) {
                sum += GCD(i, GCD(j, k));
            }
        }
    }
    cout << sum << endl;
}

fn main() -> int {
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}




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

using namespace std;

#define llong long long 
typedef struct data{
	vector<int> way;
	vector<int> waycost;
	int useway;
	int cost;
}data;

data d[101];
bool ok[101];
int sum;
int hownum;

void solve(int N, int before){
	for(int i = 0; i < d[N].way.size(); i++){
		if(d[N].cost + d[N].waycost[i] < d[d[N].way[i] ].cost){
			d[d[N].way[i] ].cost = min(d[d[N].way[i]].cost, d[N].cost + d[N].waycost[i]);
			d[d[N].way[i]].useway = N;
		}
	}
}

int main(){
	fill_n(ok, 101, false);
	int howway;
	int num;
	cin >> hownum;
	for(int i = 0; i < hownum; i++){
		cin >> num;
		cin >> howway;
		for(int j = 0; j < howway; j++){
			int w,c;
			cin >> w >> c;
			d[num].way.push_back(w);
			d[num].waycost.push_back(c);
		}

		if(num == 0) d[num].cost = 0;
		else d[num].cost = 10000000;
	}

	for(int j = 0; j < hownum; j++){
		for(int i = 0; i < hownum; i++){
			solve(i, -1);
		}
	}

	for(int i = 0; i < hownum; i++){
		cout << i << " " << d[i].cost << endl;
	}
	return 0;
}

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

const int INF = 1000000000;

int main() {
  int n;
  cin >> n;
  vector<int> h(n,0);
  rep(i,0,n) cin >> h[i];
  vector<int> dp(n+10,INF);
  dp[0] = 0;
  rep(i,0,n) {
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]));
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]));
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 3944
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  	if(input[0] + input[1] >= input[2]){
       console.log("Yes");
       }else{
        console.log("No"); 
       }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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



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

int main(){
  int N ;
  cin >> N ;
  int L[10] ;
  int sum=0 ;
  for(int i=0;i<N;i ++){
    cin >> L[i]  ;
    sum += L[i] ;
  }
  string ans="Yes" ;
  for(int i=0;i<N;i ++){
    if(sum-L[i] <= L[i]){
      ans = "No" ;
      break ;
    }
  }
  cout << ans << endl ;
}

Measured memory_bytes: 256
#N, M = map(int,input().split())
#AB=[]
#N = int(input())
C = input()
#D, T, S=map(int,input().split())
#C = []
#for i in range(N):
#    C.append(list(map(int,input().split())))
if C == "0":
    print("1")
else:
    print("0")

Measured memory_bytes: 9012
use std::io::{self, BufRead};
use std::mem::swap;

const M: usize = 1000000007;

fn create_div_floor(n: usize) -> Vec<usize> {
  let mut divfloor: Vec<usize> = Vec::new();
  let mut i: usize = 1;
  while i * i <= n {
    divfloor.push(i);
    i += 1;
  }
  let j = divfloor.len();
  for i in (0..j) {
    let k = n / divfloor[j-i-1];
    if *(divfloor.last().unwrap()) != k {
      divfloor.push(k);
    }
  }
  divfloor
}

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let (n, k) = (xs[0], xs[1]);
  let df = create_div_floor(n);
  let mut counts = df.clone();
  for l in 0..(k-1) {
    let mut temp = vec![0; df.len()];
    temp[0] = counts[df.len()-1];
    for i in 1..df.len() {
      let j = df.len() - i - 1;
      let k = df[i] - df[i-1];
      temp[i] = (temp[i-1] + (k * counts[j] % M)) % M;
    }
    swap(&mut counts, &mut temp);
  }
  println!("{}", counts[df.len()-1]);
}

Measured memory_bytes: 7812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9 + 55;

int n;
string s;
map<pair<string, string>, ll> cnt;

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

    cin >> n;

    cin >> s;

    for(int bitmask0 = 0; bitmask0 < (1 << n); bitmask0++){
        string a = "", b = "";
        for(int i = 0; i < n; i++){
            if(bitmask0 & (1 << i)){
                a.push_back(s[i]);
            } else {
                b.push_back(s[i]);
            }
        }

        cnt[make_pair(a, b)]++;
    }

    ll fRes = 0;
    for(int bitmask = 0; bitmask < (1 << n); bitmask++){
        string a = "", b = "";
        for(int i = n - 1; i >= 0; i--){
            if(bitmask & (1 << i)){
                a.push_back(s[n + i]);
            } else {
                b.push_back(s[n + i]);
            }
        }

        fRes += cnt[make_pair(a, b)];
    }

    cout << fRes << '\n';

    return 0;
}


Measured memory_bytes: 91904
#include <stdio.h>
#include <string.h>


int q, i, j, k, m, n, c[1001][1001], ans[151];
char x[1001], y[1001];

int main(void)
{

  scanf("%d", &q);
  for (k = 0; k < q; k++) {
    scanf("%s", x);
    scanf("%s", y);
    m = strlen(x);
    n = strlen(y);
    for (i = 1; i <= m; i++) {
      c[i][0] = 0;
    }

    for (j = 1; j <= n; j++) {
      c[0][j] = 0;
    }

    for (i = 1; i <= m; i++) {
      for (j = 1; j <= n; j++) {
        if (x[i - 1] == y[j - 1]) {
          c[i][j] = c[i - 1][j - 1] + 1;
        }
        else if (c[i - 1][j] >= c[i][j - 1]) {
          c[i][j] = c[i - 1][j];
        }
        else {
          c[i][j] = c[i][j - 1];
        }
      }
    }
    ans[k] = c[m][n];
  }

  for (i = 0; i < q; i++) {
    printf("%d\n", ans[i]);
  }

  return 0;
}

Measured memory_bytes: 4516
from collections import *
from heapq import *
from itertools import *
from fractions import gcd

from decimal import *
import copy
from bisect import *
import time
import sys
import math
sys.setrecursionlimit(10**7)
A,B=map(int,input().split())
B-=1
count=0
while B>0:
    B-=A-1
    count+=1
print(count)


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

int main(int argc, char const *argv[])
{
    int n, m;
    cin >> n >> m;
    if (n <= m)
    {
        cout << "unsafe" << endl;
    }
    else
    {
        cout << "safe" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n, d;
    cin >> n >> d;
    double x[10][10] = {0};
    ll res = 0;
    REP(i, n)
    {
        REP(j, d)
        {
            cin >> x[i][j];
        }
    }
    FOR(i, 0, n - 1)
    {
        FOR(j, i + 1, n)
        {
            double dist = 0;
            // debug(i + 1);
            // debug(j + 1);
            REP(k, d)
            {
                // debug(x[i][k]);
                // debug(x[j][k]);
                // debug((x[i][k] - x[j][k]));
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            // debug(dist);
            dist = sqrt(dist);
            // debug(dist);
            double integral_part = 0;
            double fractional_part = modf(dist, &integral_part);
            if (fractional_part == 0)
            {
                res++;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint L, R;
  cin >> L >> R;
  lint ans = 0;
  REP(x, 60) {
    vector<vector<vector<lint>>> dp(61, vector<vector<lint>>(2, vector<lint>(2)));
    dp[60][0][0] = 1;
    IREP(k, 60) {
      lint l = L>>k&1;
      lint r = R>>k&1;
      REP(i, 2) REP(j, 2) {
        //00
        if(k != x) {
          if(l == 0 || i == 1) {
            if(r == 0) dp[k][i][j] = (dp[k][i][j] + dp[k+1][i][j]) % MOD;
            else dp[k][i][min(1, j+1)] = (dp[k][i][min(1, j+1)] + dp[k+1][i][j]) % MOD;
          }    
        }
        if(k > x) continue;
        //10
        if(k != x) {
          if((l == 0 || i == 1) && (r == 1 || j == 1)) {
            dp[k][i][j] = (dp[k][i][j] + dp[k+1][i][j]) % MOD;
          }    
        }
        //11
        if(r == 1 || j == 1) {
          if(l == 1) dp[k][i][j] = (dp[k][i][j] + dp[k+1][i][j]) % MOD;
          else dp[k][min(1, i+1)][j] = (dp[k][min(1, i+1)][j] + dp[k+1][i][j]) % MOD;
        } 
      }
    }
    REP(i, 2) REP(j, 2) ans = (ans + dp[0][i][j]) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3644
def s(x):
  ans = 0
  while x > 0:
    ans += x % 10
    x /= 10
  return ans

n,a,b=map(int,raw_input().split())
ans = 0
for x in range(1,n+1):
  if a <= s(x) <= b:
    ans += x
print ans
    

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

int main(){
    string x; cin >> x;
    stack<char> st;
    st.push(x[0]);
    for(int i=1;i<x.size();i++){
        if(st.empty()){
            st.push(x[i]);
            continue;
        }
        char tmp=st.top();
        if(tmp=='S'&&x[i]=='T'){
            st.pop();
        }else{
            st.push(x[i]);
        }
    }
    if(st.empty()){
        cout << 0 << endl;
    }else{
        cout << st.size() << endl;
    }
    
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define M_PI 3.14159265358979323846
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> ipair;
typedef pair<ll, ll> llpair;

/*
    Author: Koushik Sahu
    Created: 09 September 2020 Wed 12:17:30
*/

string s, t;
int dp[3001][3001];
char ans[3001][3001];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin>>s>>t;
    int n = s.length();
    int m = t.length();
    for(int i=0; i<=n; i++) dp[i][0] = 0;
    for(int j=0; j<=n; j++) dp[0][j] = 0;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            ans[i][j] = '.';
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(s[i-1]==t[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
                ans[i][j] = 'M';
            }else{
                if(dp[i-1][j]>=dp[i][j-1]){
                    dp[i][j] = dp[i-1][j];
                    ans[i][j] = 'U';
                }else{
                    dp[i][j] = dp[i][j-1];
                    ans[i][j] = 'L';
                }
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    string answer = "";
    int p=n, q=m;
    while(p>=0 && q>=0 && ans[p][q]!='.'){
        if(s[p-1]==t[q-1]) answer += s[p-1];
        if(ans[p][q]=='U'){
            p -= 1;
        }else if(ans[p][q]=='L'){
            q -= 1;
        }else{
            p -= 1;
            q -= 1;
        }
    }
    reverse(answer.begin(), answer.end());
    cout<<answer<<"\n";
    return 0;
}

Measured memory_bytes: 47560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>//string型を使うならインクルード
#include <functional>
/*
全ての文字列を辞書順にソートして、
それを早い順にくっつけていく
*/

using namespace std;
int N,L;
int main(){
    cin >> N >> L;
    vector<string> S(N,"");
    string str;
    for(int d = 0; d < N; d++) {
        cin >> str;
        S[d] = str;
    }
    //sort(S.begin(),S.end(),std::greater<string&>());
    sort(S.begin(),S.end(),std::less<string&>());
    
    for(auto s : S) cout << s ;
    cout << endl;
    

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())

AC = 0
pena = 0

lst = [0] * N
for _ in range(M):
    a, b = map(str, input().split())
    a = int(a) - 1
    if lst[a] < 0:
        continue
    else:
        if b == 'WA':
            lst[a] += 1
        else:
            AC += 1
            pena += lst[a]
            lst[a] = -1

print (AC, pena)

Measured memory_bytes: 3828
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class Main {

	static Scanner sc = new Scanner(System.in);

	static class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		public FastScanner(InputStream source) {
			in = source;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte()) return buffer[ptr++];
			else return -1;
		}

		private static boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext()) throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext()) throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args){

		solve_abc166_c();
	}
  
  	public static void solve_abc166_c(){

		FastScanner sc = new FastScanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		long[] h = new long[n];
		for(int i=0;i<n;i++) h[i] = sc.nextLong();
		
		boolean[] x = new boolean[n];
		Arrays.fill(x, true);
		
		for(int i=0;i<m;i++){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			
			if(h[a] > h[b]) x[b] = false;
			else if(h[a] < h[b]) x[a] = false;
			else{
				x[a] = false;
				x[b] = false;
			}
		}
		
		int count = 0;
		for(int i=0;i<x.length;i++){
			if(x[i]) count++;
		}
		
		System.out.println(count);
	}
}

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

const int mod = 1000000007, N = 4005;

int n, m, k, len, dp[N][N], ans = 0;

void reduce(int &x) { x += x >> 31 & mod; }

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> m >> k, len = (n + m - 1) / (k - 1);
	dp[0][0] = 1;
	for (int i = 1; i <= len; ++i) {
		for (int j = 0; j <= m; ++j) {
			for (int l = 0; l < k && j + l <= m; ++l)
				reduce(dp[i][j + l] += dp[i - 1][j] - mod);
		}
		int sum = i * (k - 1) + 1;
		for (int j = m; j >= sum - n && j >= 0; j -= k - 1)
			if ((sum - j - n) % (k - 1) == 0)
				reduce(ans += dp[i][j] - mod), reduce(ans -= dp[i - 1][j]);
	}
	std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 62080
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static final int[] dx={0,1,0,-1},dy={1,0,-1,0};
	public static void main(String[]A){
		int h=gInt(),w=gInt();
		char[][] f=new char[h][w];
		for(int i=0;i<h;++i)
			s.next().getChars(0,w,f[i],0);
		for(int i=0;i<h;++i){
			loop:
			for(int j=0;j<w;++j){
				if(f[i][j]=='#'){
					for(int d=0;d<4;++d){
						int I=i+dy[d];
						int J=j+dx[d];
						if(0<=I&&I<h&&0<=J&&J<w&&f[I][J]=='#')
							continue loop;
					}
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


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

ll MOD = 998244353;

int main()
{

    int N;
    cin >> N;
    int first;
    cin >> first;
    if(first > 0){
        cout << 0 << endl;
        return 0;
    }
    vector<int> distanceCount(N, 0);
    distanceCount.at(first)++;
    int maxDistance = 0;
    for (int i = 0; i < N - 1; i++)
    {
        int d;
        cin >> d;
        distanceCount.at(d)++;
        maxDistance = max(maxDistance, d);
    }
    if(distanceCount.at(0) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll answer = 1;
    int prev = 1;
    for (int i = 1; i <= maxDistance; i++)
    {
        for(int j = 1; j <= distanceCount.at(i); j++){
            answer = (answer * prev) % MOD;
        }
        prev = distanceCount.at(i);
    }

    cout << answer << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
  ll N;
  ll A[2222222];
  cin >> N;
  ll i;
  for(i=2;i<=N;i++)
    cin >> A[i];
  ll count[2222222] = {0};
  for(i=2;i<=N;i++)
    count[A[i]]++;
  for(i=1;i<=N;i++)
    cout << count[i] << endl;
}

Measured memory_bytes: 22564
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,j,a,d[200010][25]={};
  
  cin >> n;
  
  for (i=1;i<=n;i++){
    cin >> a;
    for (j=0;j<20;j++){
      d[i][j]=d[i-1][j]+a%2;
      a >>= 1;
    }
  }
  
  int l,r=1;
  ll ans=0;
  for (l=0;l<n;l++){
    bool ok=true;
    while (r<=n){
      for (j=0;j<20;j++){
        if (d[r][j]-d[l][j]>1){
          ok=false;
          break;
        }
      }
      if (!ok) break;
      r++;
    }
    r--;
    ans+=r-l;
    
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 19840
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;

int main(void){
  ll n,a,b;
  cin >> n >> a >> b;
  ll ans = (n/(a+b))*a;
  if(n%(a+b) < a) ans += n%(a+b);
  else ans += a;

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


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

#define cget getchar_unlocked
#define cput putchar_unlocked

inline int in() {
  int n = 0; short c;
  while ((c = cget()) >= '0') n = n * 10 + c - '0';
  return n;
}

inline void out(int n) {
  short res[10], i = 0;
  do { res[i++] = n % 10, n /= 10; } while (n);
  while (i) cput(res[--i] + '0');
}

class SCC {
private:
  const int N;
  vector<vector<int>> G, R;
  vector<int> ord, low;
  stack<int> st;
  void dfs(const int u, int &tm) {
    ord.at(u) = low.at(u) = tm++, st.push(u);
    for (int v : G.at(u)) {
      if (ord.at(v) < 0) {
        dfs(v, tm);
        low.at(u) = min(low.at(u), low.at(v));
      } else if (cmp.at(v) < 0) {
        low.at(u) = min(low.at(u), ord.at(v));
      }
    }
    if (ord.at(u) == low.at(u)) {
      R.push_back(vector<int>{});
      while (true) {
        const int v = st.top();
        st.pop();
        cmp.at(v) = cnt;
        R.back().push_back(v);
        if (v == u) break;
      }
      cnt++;
    }
  }

public:
  vector<vector<int>> graph;
  vector<int> cmp;
  int cnt;
  SCC(const int n) : N(n), G(n), ord(n, -1), low(n), cmp(n, -1), cnt(0) {}
  void add(const int from, const int to) { G.at(from).push_back(to); }
  vector<vector<int>> solve() {
    int tm = 0;
    for (int i = 0; i < N; i++) {
      if (ord.at(i) < 0) dfs(i, tm);
    }
    for (int i = 0; i < N; i++) cmp.at(i) = cnt - 1 - cmp.at(i);
    reverse(R.begin(), R.end());
    return R;
  }
  vector<vector<int>> build() {
    graph.resize(cnt);
    for (int i = 0; i < N; i++) {
      for (int j : G.at(i)) {
        if (cmp.at(i) != cmp.at(j)) {
          graph.at(cmp.at(i)).push_back(cmp.at(j));
        }
      }
    }
    return graph;
  }
};

signed main() {
  int N = in(), M = in();  
  SCC SC(N);
  for (int i = 0; i < M; i++) {
    int a = in(), b = in();
    SC.add(a, b);
  }

  auto G = SC.solve();
  out(G.size()), cput('\n');
  for (int i = 0, h = G.size(); i < h; i++) {
    out(G.at(i).size());
    for (int j = 0, w = G.at(i).size(); j < w; j++) {
      cput(' '), out(G.at(i).at(j));
    }
    cput('\n');
  }
}

Measured memory_bytes: 87200
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

int n;
vector<pair<int, int>> G[100005];
int ans[100010];
int a[100005], b[100005];
bool u[100010];

void dfs(int k) {
    int ng = -1;
    u[k] = false;
    for (int i = 0; i < G[k].size(); i++) {
        if (!u[G[k][i].first]) ng = ans[G[k][i].second];
    }
    int idx = 0;
    if (ng == 0) idx = 1;
    for (int i = 0; i < G[k].size(); i++) {
        if (u[G[k][i].first]) {
            ans[G[k][i].second] = idx;
            dfs(G[k][i].first);
            idx++;
        }
        if (ng == idx) idx++;
    }

}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        u[i] = true;
        cin >> a[i] >> b[i];
        a[i]--;  b[i]--;
        G[a[i]].emplace_back(b[i], i);
        G[b[i]].emplace_back(a[i], i);
    }
    u[n - 1] = true;
    int mx = 0, mx_idx = -1;
    for (int i = 0; i < n; i++) {
        if (mx < G[i].size()) {
            mx = max(mx, int(G[i].size()));
            mx_idx = i;
        }
    }
    cout << mx << endl;

    dfs(mx_idx);

    for (int i = 0; i < n - 1; i++) cout << ans[i] + 1 << endl;




}


Measured memory_bytes: 8960
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b = LI()

    return a - b + 1



print(main())


Measured memory_bytes: 7112
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(b - 1, n);
  cout << a * x / b - a * (x / b) << endl;
}

Measured memory_bytes: 3620
n=int(input())
nums=list(map(int,input().split()))

def counting_sort(nums,n):
    max_nums=max(nums)
    basket=[0 for i in range(max_nums+1)]
    for i in range(n):
        key=nums[i]
        basket[key]+=1

    answer=[]
    for i in range(len(basket)):
        if basket[i]!=0:
            for j in range(basket[i]):
                answer.append(i)
    return answer

answer=counting_sort(nums,n)
print(' '.join(map(str,answer)))



Measured memory_bytes: 242236
#include <stdio.h>
#include <math.h>

#define PI 3.1415926535

typedef struct {
    double x;
    double y;
} point;

void calcKochCurvePoint(int n, point *p1, point *p2);
void printPoint(point *p);

int main(void)
{
    int n;
    scanf("%d", &n);

    point p1 = {0.0, 0.0};
    point p2 = {100.0, 0.0};

    printPoint(&p1);
    calcKochCurvePoint(n, &p1, &p2);
    printPoint(&p2);

    return 0;
}

void calcKochCurvePoint(int n, point *p1, point *p2)
{
    if (n == 0) {
        return ;
    }

    point s, t, u;
    s.x = (2 * p1->x + p2->x) / 3;
    s.y = (2 * p1->y + p2->y) / 3;
    t.x = (p1->x + 2 * p2->x) / 3;
    t.y = (p1->y + 2 * p2->y) / 3;
    u.x = s.x + (t.x - s.x) * cos(PI / 3) - (t.y - s.y) * sin(PI / 3);
    u.y = s.y + (t.x - s.x) * sin(PI / 3) + (t.y - s.y) * cos(PI / 3);

    calcKochCurvePoint(n - 1, p1, &s);
    printPoint(&s);
    calcKochCurvePoint(n - 1, &s, &u);
    printPoint(&u);
    calcKochCurvePoint(n - 1, &u, &t);
    printPoint(&t);
    calcKochCurvePoint(n - 1, &t, p2);
}

void printPoint(point *p)
{
    printf("%lf %lf\n", p->x, p->y);
}

Measured memory_bytes: 636
while True:
    n, x = map(int, input().split())
    if (n,x) == (0,0) : break
    cnt = 0
    if 3*(n-1) >= x:
        a_max = x//3 - 1
        if 2*n -1 < x:
            a_min = x - (2*n-1)
        else :
            a_min = 1
        for a in range(a_min,a_max+1):
            b_max = (x-a-1)//2
            b_min = (x-a) - n
            b_min = b_min if b_min > a+1 else a+1
            cnt += b_max - b_min +1
    print(cnt)

Measured memory_bytes: 7636
N,K=map(int,input().split())
MAX=(N-1)*(N-2)//2
if K>MAX:
    print(-1)
else:
    print(N-1+MAX-K)
    for i in range(N-1):
        print(1,2+i)
    from itertools import combinations
    n=MAX
    for a,b in combinations(range(2,N+1),2):
        if n==K:
            break
        print(a,b)
        n-=1

Measured memory_bytes: 3608
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int h,w;
  int i,j;
  while(1){
    cin>>h>>w;
    if(h==0 && w==0)break;
    int len=h*h+w*w;
    int ans=0;
    for(i=h+1;i*i<len/2;i++){//i:tate
      double left=len-i*i;
      // printf("i*i=%d,left=%f,yoko=%f\n",i*i,left,sqrt(left));
      if(sqrt(left)-(int)sqrt(left)<EPS){
	ans=i; 
	break;
      }
    }
    if(ans>0){
      cout<<ans<<" "<<sqrt(len-ans*ans)<<endl;
      goto END;
    }
    while(1){
      len++;
      for(i=1;i*i<len/2;i++){
	double left=len-i*i;
	//	printf("len=%d,i*i=%d,left=%f,yoko=%f\n",len,i*i,left,sqrt(left));
	left=sqrt(left);
	if(left-(int)left<EPS){
	  cout<<i<<" "<<left<<endl;
	  goto END;
	}
      }

    }
  END:;

  }
}

Measured memory_bytes: 3168
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = double.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        double ans = 2 * n * Math.PI;
        // 出力
        Console.WriteLine(ans);
    }
}

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

int main() {
    string S, T;
    cin >> S >> T;
    int cnt = 0;
    for (int i = 0, len = S.length(); i < len; i++) {
        if (S.at(i) != T.at(i))
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3824
#include <iostream>
using namespace std;
int main(){
    int H,W;
    for(int i=0;i<999999;i++){
        cin >> H >> W;
        if(H==0 && W==0){
            break;
        }
        for(int j=0;j<H;j++){
            for(int k=0;k<W/2+1;k++){
                if(j%2==0 && k!=W/2){
                 cout << "#" << ".";
                             }  
                else if(j%2!=0 && k!=W/2){
                    cout << "." << "#";
                }
                else if(j%2==0 && W%2==1){
                    if(k==W/2){
                        cout << "#";
                    }
                }
                else if(j%2!=0 && W%2==1){
                    if(k==W/2){
                        cout << ".";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>

std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main(void)
{
	int a, b, k, lc;
	std::cin >> a >> b >> k;
	lc = gcd(a, b);
	std::vector<int> r = enum_div(lc);
	r.push_back(lc);
	std::sort(r.begin(), r.end(), std::greater<int>());
	int j = 1;
	for(auto i : r){
		if(j == k)std::cout << i << std::endl;
		j++;
    }
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
	// "sort"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func Pow(b, e int) int {
	result := 1
	for i := 0; i < e; i++ {
		result = result * b
	}
	return result
}

var permutationResult = make([]int, 0)
var used []bool
func Permutation(list *[]int, index int, current int) {

	current *= 10
	current += (*list)[index]

	if Pow(10, len(*list)-1) <= current {
		permutationResult = append(permutationResult, current)
		return
	}

	// fmt.Println(list)
	for i := 0; i < len(*list); i++ {
		if used[i] {
			continue
		}
		used[i] = true
		Permutation(list, i, current)
		used[i] = false
	}

}
func CreatePermutation(list []int) []int {
	used = make([]bool, len(list))
	for i := 0; i < len(list); i++ {
		used[i] = true
		Permutation(&list, i, 0)
		used[i] = false
	}
	return permutationResult
}

func Print(i int) {
	s := strconv.Itoa(i)
	t := strings.Split(s, "")
	u := strings.Join(t, " ")
	fmt.Println(u)
}

func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	theNumber := 0
	fmt.Scanf("%d", &n)
	list := make([]int, n)
	for i := 1; i <= n; i++ {
		list[i-1] = i
		theNumber += i
		theNumber *= 10
	}
	theNumber /= 10

	// sort.Slice(list, func(lhs, rhs int) bool {
	// 	return list[lhs] < list[rhs]
	// })
	p := CreatePermutation(list)
	for i := range p {
		s := strconv.Itoa(p[i])
		t := strings.Split(s, "")
		u := strings.Join(t, " ")
		con.Println(u)
	}
}


Measured memory_bytes: 12688