akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  double l;cin >> l;
  double res = (l/3.) * (l/3.) * (l/3.);
  printf("%.7f\n", res);
  return 0;
}


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



#define bstN 500000


int size;
int t[bstN];
int lc[bstN];
int rc[bstN];
  
  

  
void insert(int v){
  int i=0;
  while(i<size){
    int& child=(v<t[i]?lc[i]:rc[i]);
    if(child==-1)child=size;
    i=child; 
  }
  lc[size]=rc[size]=-1;
  t[size++]=v;
}

void preord(int pos){
  if(pos==-1||pos==size)return;
  preord(lc[pos]);
  printf(" %d",t[pos]);
  preord(rc[pos]);
}
  
void inord(int pos){
  if(pos==-1||pos==size)return;
  printf(" %d",t[pos]);
  inord(lc[pos]);
  inord(rc[pos]);
}





int main(){

  int n,a;
  char str[100];
  scanf("%d",&n);
  
  while(n--){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&a);
      insert(a);
    }else{
      preord(0);
      printf("\n");
      inord(0);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 7056
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>

using namespace std;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  vector<int> a(n);

  for (int i = 0; i < n; i++){
    cin >> a[i];
  }

  for (int i = k; i < n; i++){
    if (a[i] > a[i-k]){
      cout << "Yes\n";
    }else{
      cout << "No\n";
    }
  }
    
  return 0;
}

Measured memory_bytes: 3956
N = int(input())
v_T = 1
v_A = 1
for _ in range(N):
    t, a = list(map(int, input().split()))
    d = max(((-v_T)//t)*(-1), ((-v_A)//a)*(-1))
    v_T = d*t
    v_A = d*a


print(v_T+v_A)


Measured memory_bytes: 3060
#include<string>
#include<iostream>
using namespace std;
string s;
int main(){
	cin>>s;
	if(s[0]==s[s.size()-1])
	  if(s.size()%2==1) cout<<"Second";
	  else cout<<"First";
	else
	  if(s.size()%2==1) cout<<"First";
	  else cout<<"Second";
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <sstream>
#include <vector>
#include <string>
#include <iomanip>
#include <bitset>
using namespace std;
#define INF	100000000
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define SS stringstream
#define rep(i,n) for(int i = 0; i < n; i++)
#define sz(x) ((int)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define clr(a,b) memset((a),(b),sizeof(a))
typedef pair<int, int> P;
typedef long long int ll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<P> Vp;
typedef priority_queue<P, vector<P>, greater<P> > PQ;

struct edge{int to, cost; };
struct road{int from, to, dis, cost;};
int n, m;
/*
bool asc( const road& left, const road& right ) {
    return left.from == right.from ? left.to < right.to : left.from < right.from;
}
*/

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	while(cin >> n >> m){
		int d[10000], city[10000];
		vector<edge> G[10000];
		vector<road> vec;
		ll ans = 0;
		if(n == 0 && m == 0) break;
		fill(city,city+n,INF);
		rep(i,m){
			int u,v,d,c; cin >> u >> v >> d >> c;
			u--; v--;
			edge e1 = {v,d}, e2 = {u,d};
			road r1 = {u,v,d,c}, r2 = {v,u,d,c};
			G[u].pb(e1); G[v].pb(e2);
			vec.pb(r1); vec.pb(r2);
		}
		
		PQ que;
		fill(d,d+n,INF);
		d[0] = 0;
		que.push(P(0,0));
		while(!que.empty()){
			P p = que.top(); que.pop();
			int v = p.sec;
			if(d[v] < p.fi) continue;
			rep(i,G[v].size()){
				edge e = G[v][i];
				if(d[e.to] > d[v]+e.cost){
					d[e.to] = d[v]+e.cost;
					que.push(P(d[e.to],e.to));
				}
			}
		}
		//sort(vec.begin(), vec.end(), asc);
		
		rep(i,2*m){
			road r = vec[i];
			//cout << r.from << " " << r.to << " " << r.dis << " " << r.cost << endl;
			if(d[r.from] == d[r.to]+r.dis){
				//cout << d[r.from] << " " << d[r.to] << " " << r.dis << endl;
				if(city[r.from] == INF){
					city[r.from] = r.cost;
					ans += r.cost;
				}
				else if(city[r.from] > r.cost){
					ans += r.cost-city[r.from];
					city[r.from] = r.cost;
				}
			}
			//cout << ans << endl;
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 3268
#include <iostream>

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

    int A[int(1e5)+10];
    int S = 0;
    A[0] = 0;
    
    for(int i=1; i<=n; ++i) {
        std::cin >> A[i];
        S += std::abs(A[i] - A[i-1]);
    }

    A[n+1] = 0;
    S += std::abs(A[n+1] - A[n]);

    for(int j=1; j<=n; ++j) {
        int answer = S + std::abs(A[j-1] - A[j+1]) - (std::abs(A[j-1] - A[j]) + std::abs(A[j+1] - A[j]));
        std::cout << answer << std::endl;
    }

}

Measured memory_bytes: 1664
main :: IO ()
main = do
  ls1 <- getLine
  ls2 <- getLine
  let t1 = makeTuple (tail (map read (words ls1)))
      t2 = makeTuple (tail (map read (words ls2)))
  putStrLn $ solve t1 t2

makeTuple :: [Int] -> [(Int,Int)]
makeTuple [] = []
makeTuple (h:m:r) = (h,m):(makeTuple r)

solve :: [(Int,Int)] -> [(Int,Int)] -> String
solve t1 t2 = format (sort (t1 ++ t2))
  where
    sort :: [(Int,Int)] -> [(Int,Int)]
    sort [] = []
    sort ((h,m):r) = (sort lower) ++ [(h,m)] ++ (sort higher)
      where
        lower = filter (\(a,b) -> (a < h) || ((a == h) && b < m)) r
        higher = filter (\(a,b) -> (a > h) || ((a == h) && b > m)) r

    format :: [(Int,Int)] -> String
    format [] = []
    format [(a,b)] = deform (a,b)
    format ((a,b):r) = (deform (a,b)) ++ " " ++ (format r)

    deform :: (Int,Int) -> String
    deform (a,b) = (show a) ++ ":" ++ (replicate (2 - length (show b)) '0') ++ (show b)

Measured memory_bytes: 4116
letters = 'abcdefghijklmnopqrstuvwxyz'
counts = [0] * 26
sentence = []

s = input()
while s:
    try:
        sentence += s
        s = input()
    except EOFError:
        break

for c in sentence:
    i = letters.find(c.lower())
    if i >= 0:
        counts[i] += 1
        
for c in letters:
    print(c, ':', counts[letters.find(c)])



Measured memory_bytes: 5572
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int n;
signed main() {
	cin >> n;
	if (n % 2 == 0) {
		cout << n * (n - 2) / 2 << endl;
		for (int i = 1; i <= n - 1; i++) {
			for (int j = i + 1; j <= n; j++) {
				if (n + 1 - i == j)continue;
				cout << i << " " << j << endl;
			}
		}
	}
	else {
		cout << (n - 1) * (n - 1) / 2 << endl;
		for (int i = 1; i <= n - 1; i++)cout << n << " " << i << endl;
		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j <= n - 1; j++) {
				if (n - i == j)continue;
				cout << i << " " << j << endl;
			}
		}
	}
	ggr
}

Measured memory_bytes: 256
"""
出典:https://atcoder.jp/contests/abc005/tasks/abc005_3
"""
def main():
  N = int(input())
  red_l = [list(map(int,input().split())) for _ in range(N)]
  blue_l = [list(map(int,input().split())) for _ in range(N)]
  red_l=sorted(red_l,key=lambda x:-x[1])
  blue_l=sorted(blue_l,key=lambda x:x[0])

  count=0
  for r in red_l:
    for b in blue_l:
      if r[0]<b[0] and r[1]<b[1]:
        count +=1
        blue_l.remove(b)
        break
  print(count)

if __name__=="__main__":
  main()



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

int main() {
    int count = 0;
    int n; 
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    
    for(int i = 0; i < n; i++) {
        int mini = i;
        for (int j = i; j < n; j++) {
            if(arr[j] < arr[mini]) {
                mini = j;
            }
        }
        int temp = arr[i];
        arr[i] = arr[mini];
        arr[mini] = temp;
        if(mini != i) {
            count++;
        }
    }
    
    for(int i = 0; i < n; i++) {
        cout << arr[i];
        if(i == n-1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    
    cout << count << endl;
    
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string S; cin >> S;
    vector<string> W{"Sunny", "Cloudy", "Rainy"};
    REP(i,3){
        if(S==W[i]){
            cout << W[(i+1)%3] << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main()
{
    long long N;
    cin >> N;

    vector<long long> sumVec(N, 0);

    long long a;
    cin >> a;
    sumVec[0] = a;

    long long total = a;

    for (long long i = 1; i < N; i++)
    {
        cin >> a;
        sumVec[i] = a + sumVec[i - 1];
        total += a;
    }

    long long ans = LLONG_MAX;
    for (long long i = 0; i < N - 1; i++)
    {
        ans = min(ans, abs(sumVec[i] - (total - sumVec[i])));
    }

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

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
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; }
//end

constexpr ll c=200'000'000'000'000'000LL;
int N; ll x[11000],y[11000];
bool que(ll n,ll r){if(n<0||r<0||n<r)return 0; return (n&r)==r;}
bool col(ll a){
   bool res=0;
   rep(i,0,N)if(a>=x[i])res^=que(c-x[i]-y[i],a-x[i]);
   return res;
}
ll cnt[3];
void calc(ll n,ll t){
   if(t<0){rep(i,0,3)cnt[i]=0; return;}
   chmin(t,n); ll dp[64][3][2]={}; dp[60][0][1]=1;
   rrep(i,59,-1)rep(j,0,3)rep(k,0,2)if(dp[i+1][j][k]){
      rep(nxt,0,2){
         if((n>>i&1)==0&&nxt)continue;
         if(k&&nxt&&(t>>i&1)==0)continue;
         int nj=(j+(nxt?(i&1?2:1):0))%3,nk=k;
         if(nxt==0&&(t>>i&1))nk=0;
         dp[i][nj][nk]+=dp[i+1][j][k];
      }
   }
   rep(i,0,3)cnt[i]=dp[0][i][0]+dp[0][i][1];
}
ll rng(ll n,ll lb,ll rb,int r){
   calc(n,rb); ll res=cnt[r];
   calc(n,lb); res-=cnt[r];
   return res;
}
bool flag(ll lb,ll rb,int r){
   bool res=0;
   rep(i,0,N)res^=rng(c-x[i]-y[i],lb-x[i],rb-x[i],((r-x[i])%3+3)%3)&1;
   return res;
}

//reference:https://physics0523.hatenablog.com/entry/2019/02/26/190724
int main(){
   scanf("%d",&N); rep(i,0,N)scanf("%lld%lld",&x[i],&y[i]);
   ll lb=-c/2,rb=c/2;
   while(rb-lb>1){
      ll mid=(lb+rb)>>1; bool f=0;
      rep(r,0,3)if(flag(lb,mid,r)){f=1; break;}
      if(f)rb=mid; else lb=mid;
   }
   assert(col(rb));
   ll x1=rb,x2=rb;
   rrep(k,62,-1){
      if(col(x1-(1LL<<k)))x1-=1LL<<k;
      if(col(x2+(1LL<<k)))x2+=1LL<<k;
   }
   printf("%lld %lld\n",x1,c-x2);
   return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main()
{
	int h, w, i, j;
	while(1)
	{
		scanf("%d %d", &h, &w);
		if (h == 0 && w == 0) { break; }
		for (i = 1; i <= h; i++) {
			for (j = 1; j <= w; j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int ans=0;
		if(b%a==0) {
			ans=a+b;
			System.out.println(ans);
		}else {
			ans=b-a;
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 21716
"""
パーティション
ある基準の値を元に分類わけするアルゴリズム
12
13 19 9 5 12 8 7 4 21 2 6 11
"""

def partition(A, n):
    x = A[n-1]
    i = 0
    j = 0
    for k in range(n):
        if A[k] <= x:
            tmp = A[i]
            A[i] = A[k]
            A[k] = tmp
            i += 1
        j += 1
    return i-1
            



if __name__=="__main__":
    n = int(input())
    A = list(map(int, input().split()))
    reference_index  = partition(A, n)
    A_str = []
    for x, a in enumerate(A):
        if x == reference_index:
            A_str.append("["+str(a)+"]")
        else:
            A_str.append(str(a))
    print(" ".join(A_str))
    # print(count)


Measured memory_bytes: 16592
N = int(input())
data = list(map(int, input().split(' ')))
data.sort(reverse = True)
score = 0
is_Alices_turn = True

for data in data:
    if is_Alices_turn:
        score += data
    else:
        score -= data
    is_Alices_turn = not is_Alices_turn

print(score)

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

const double EPS = 1e-10;
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
namespace std{
    bool operator < (const P& a, const P& b){
        return (a.X!=b.X) ? a.X<b.X : a.Y<b.Y;
    }
    bool operator == (const P& a, const P& b){
        return abs(a-b) < EPS;
    }
}

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char> > mat(h+2, vector<char>(w+2, '.'));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cin >> mat[i][j];
        }
    }
    reverse(mat.begin(), mat.end());

    VP cut;
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            cut.push_back(P(j,i)/abs(P(j,i)));
        }
    }
    sort(cut.begin(), cut.end());
    cut.erase(unique(cut.begin(), cut.end()), cut.end());

    int ans=0;
    for(int i=0; i<(int)cut.size(); i++){
        for(int j=0; j<2; j++){
            double eps=(j==0)?EPS: -EPS;
            int subans=0;
            double m = cut[i].Y/cut[i].X;
            for(int x=0; x<=w; x++){
                int y = m*x +1 +eps;
                if(y>h+1) break;
                if(mat[y][x] != mat[y][x+1]) subans++;
            }
            m = cut[i].X/cut[i].Y;
            for(int y=0; y<=h; y++){
                int x = m*y +1 -eps;
                if(x>w+1) break;
                if(mat[y][x] != mat[y+1][x]) subans++;
            }
            ans = max(ans, subans);
        }
    }
    cout << ans/2+1 << endl;
    return 0;
}

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

const int N = 200010;
const int mod = 1e9 + 7;
const int inv2 = (mod + 1) / 2;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

int n;

struct FUCK {
	
int tree[N];
    
inline void update(int x, int y) {
    for (; x <= n; x += x & -x) tree[x] = (tree[x] + y) % mod;
}

inline int query(int x) {
    int res = 0;
    for (; x; x -= x & -x) res = (res + tree[x]) % mod;
    return res;
}

inline int query(int l, int r) {
    return (query(r) - query(l - 1) + mod) % mod;
}

} X, Y, Z;

int A[N], num[N], pre[N], lst[N], nxt[N], ct[N];
bool fuck[N];

int main() {
	scanf("%d", &n);
	for (int i = 1, a; i <= n; i++) scanf("%d", &a), A[a]++, num[i] = a;
	for (int i = n; i >= 0; i--) A[i] += A[i + 1];
	int tot = 1; pre[0] = 1;
	for (int i = 1; i <= n; i++) {
		A[i] -= n - i, tot = (LL)tot * A[i] % mod;
		if (A[i] <= 0) return puts("0"), 0;
		int t = (LL)(A[i] - 1) * Pow(A[i], mod - 2) % mod;
		if (t) pre[i] = (LL)pre[i - 1] * t % mod;
		else pre[i] = pre[i - 1], fuck[i] = true;
	} 
	nxt[n + 1] = n + 1;
	for (int i = n; i >= 1; i--) {
		nxt[i] = nxt[i + 1];
		if (fuck[i]) nxt[i] = i;
	}
	for (int i = 1; i <= n; i++) {
		lst[i] = lst[i - 1];
		if (fuck[i]) lst[i] = i;
	}
	int res = 0;
	for (int i = 1; i <= n; i++) {
		res = (res + (LL)ct[num[i]] * tot % mod * inv2) % mod;
		if (num[i] != 1) {
			res = (res + (LL)Y.query(max(1, lst[num[i]]), num[i] - 1) * pre[num[i]] % mod
				* tot % mod * inv2) % mod;
		}
		if (num[i] != n) {
			res = (res + (LL)Z.query(num[i] + 1, n) * tot) % mod;
			res = (res - (LL)X.query(num[i] + 1, min(n, nxt[num[i] + 1] - 1)) * Pow(pre[num[i]], mod - 2) % mod
				* tot % mod * inv2 % mod + mod) % mod;
		}
		X.update(num[i], pre[num[i]]), Y.update(num[i], Pow(pre[num[i]], mod - 2)), Z.update(num[i], 1), ct[num[i]]++;
	}
	printf("%d\n", res);
}//

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

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    for(int i = 0; i <= B; i += K) {
        if(A <= i ) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3616
# coding:utf-8

a, b, k = map(int, input().split())

def eat(n):
    if n%2 == 1:
        return n-1
    return n


def send(x, y):
    x = eat(x)
    y += x/2
    return x/2, y

def play(a, b, i):
    if i%2 == 0:
        a, b = send(a, b)
    else:
        b, a = send(b, a)
    return a, b

for i in range(k):
    a, b = play(a, b, i)
    

print(int(a), int(b))

Measured memory_bytes: 3064
fn main() {
    let n = read::<usize>();
    let mut v = vec![];
    for _ in 0..n {
        let xy = read_vec::<f64>();
        v.push((xy[0], xy[1]));
    }
    /*
        let fac = {
            let mut i = &n;
            let mut f = 1;
            while i > 0 {
                f *= i;
                i -= 1;
            }
            f
        };
    */
    let mut distances = 0.0;
    for i in 0..n - 1 {
        for j in i + 1..n {
            distances += ((v[i].0 - v[j].0).powi(2) + (v[i].1 - v[j].1).powi(2)).sqrt();
        }
    }
    println!("{}", distances * 2.0 / (n as f64));
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

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

using namespace std;

int main(){
  int a,b;cin>>a>>b;

  string s;cin>>s;

//cout<<(count(s.begin(), s.end(), '-')!=1);
//cout<<(s.size()!=a+b+1);
//cout<<(s[a]!='-');


  if(count(s.begin(), s.end(), '-')!=1 || s.size()!=a+b+1 || s[a]!='-'){
    cout<<"No";
  }else{
    cout<<"Yes";
  }
  return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
c = input()

turn = 'a'

while True:

    if turn == 'a':
        if a == "":
            print('A')
            break
        turn = a[0]
        a = a[1:]

    elif turn == 'b':
        if b == "":
            print('B')
            break
        turn = b[0]
        b = b[1:]
    else:
        if c == "":
            print('C')
            break
        turn = c[0]
        c = c[1:]

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

using namespace std;

namespace {

    typedef long double real;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }

    real d;
    void input() {
        cin >> d;
    }

    const real EPS = 1e-10;

    void solve() {
        real ans = sqrt(2.0) * d;
        for (int x = 0; x <= 105; x++) {
            real z = d * d - x * x;
            if (z <= -EPS) break;
            real y = sqrt(z);
            if (y <= 1.0) {
                ans = max(ans, real(x) + 1.0);
            } else {
                ans = max(ans, x + y);
            }
        }
        cout << fixed << setprecision(12) << ans << endl;
    }
}

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

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

class Program
{

    static void Main(string[] args)
    {
        int[] input = GetInputsInt();

        int a = input[2] - Math.Min(input[0] - input[1],input[2]);

        Console.WriteLine(a);

    }



    public static int GetInputInt()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] GetInputsInt()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    public static List<int> GetInputsIntList()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToList();
    }
    public static long GetInputLong()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] GetInputsLong()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }

}


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

int main() {
    string s, t;
    cin >> s >> t;

    sort (s.begin(), s.end());
    sort (t.begin(), t.end());
    reverse (t.begin(), t.end());

    int len = min (s.length(),t.length());
    for (int i = 0; i < len; i++) {
        if (s[i] == t[i])
            continue;
        else if (s[i] < t[i]) {
            cout << "Yes" << endl;
            return 0;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    if (s.length() >= t.length())
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

void solve(){
    int N;
    cin >> N;

    int sumd = 0, sumsquared = 0;
    for (int i = 0; i < N; i++) {
        int d; cin >> d;
        sumd += d;
        sumsquared += d*d;
    }

    cout << (sumd*sumd - sumsquared) / 2 << endl;

    return;

}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
/***************************************** START OF TEMPLATE *********************************************/

#include<bits/stdc++.h>

using namespace std;

#define  SPEED          ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  f              first
#define  s              second
#define  pb             push_back
#define  INPa(a,n)      foo(i,1,n) cin>>a[i];
#define  deb2d(a,n,m)   foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}    
#define  deb1d(a,n)     foo(i,1,n)cout<<a[i]<<" ";newl;
#define  debv(a)        for(auto it: a)cout<<it<<" ";newl;
#define  deb1(a)        cout<<a<<" ";newl;
#define  deb2(a,b)      cout<<a<<" "<<b<<" ";newl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<" ";newl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d;newl;
#define  ll             long long
#define  ld             long double
#define  pll            pair<ll,ll>
#define  vll            vector<ll>
#define  vpll           vector<pll>

const ll   MOD   =  1e+9+7;
const ll   INF   =  LLONG_MAX;
const int  INFi  =  INT_MAX;
const ll   N     =  2e+5+8;

vll adj[N]; ll vis[N];
ll dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

ll test_cases = 1; randomINIT;

/*********************************************************************************************************/
/***************************************** VARIABLE DECLARATIONS *****************************************/
ll n;


/***************************************** FUNCTION IMPLEMENTATIONS **************************************/



/***************************************** START OF MAIN FUNCTION ****************************************/
void MAIN(ll tc){
    cin>>n;
    ll sum = 0;
    foo(i,1,n){
        
        ll ok3 = (i%3 == 0);
        ll ok5 = (i%5 == 0);
        //cout<<i<<" "<<ok3<<" "<<ok5;newl;
        if(!ok3 && !ok5) {
            sum += i;
        }
    }

    cout<<sum;
    newl;
}

int main(){
    SPEED;

    //cin>>test_cases;
    foo(i,1,test_cases){
        MAIN(i);
    }
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int dp[310][310][310];

int main() {
	string s, t;
	cin >> s;
	t = s;
	reverse(ALL(t));

	int n = s.size();
	int K;
	cin >> K;

	if (n == 1) {
		puts("1");
		return 0;
	}

	rep(i, n) {
		rep(j, n) {
			for (int k = 0; k <= K; ++k) {
				if (s[i] == t[j]) {
					dp[i+1][j+1][k] = max(dp[i+1][j+1][k], dp[i][j][k] + 1);
				} else {
					dp[i+1][j+1][k+1] = max(dp[i+1][j+1][k+1], dp[i][j][k] + 1);
				}
				dp[i+1][j+1][k] = max(dp[i+1][j+1][k], dp[i+1][j][k]);
				dp[i+1][j+1][k] = max(dp[i+1][j+1][k], dp[i][j+1][k]);
			}
		}
	}

	int ret = 0;

	for (int m = 0; m < n; ++m) {
		for (int k = 0; k <= K; ++k) {
			int t = dp[m][n-1-m][k] * 2 + 1;
			ret = max(ret, t);

			t = dp[m+1][n-1-m][k] * 2;
			ret = max(ret, t);
		}
	}

	cout << ret << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    ll *a = new ll[n];

    ll r = 0, l = 0;
    ll sum = 0;

    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    } 
    l = sum;

    ll ans = sum;

    for (int i = 0; i < n; i++) {
        r += a[i];
        l -= a[i];
        ans = min(ans, (ll)abs(r-l));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const int INF = 1 << 30;

int N, M;

void dfs(const vector<vector<int>>& A, set<int>& S, int& ans) {
    vector<int> cnt(M, 0);
    rep(i, 0, N) {
        rep(j, 0, M) {
            if (S.count(A[i][j])) {
                ++cnt[A[i][j]];
                break;
            }
        }
    }
    int max_sport;
    int max_participants = 0;
    rep(i, 0, M) {
        if (chmax(max_participants, cnt[i])) {
            max_sport = i;
        }
    }
    chmin(ans, max_participants);
    S.erase(max_sport);
    if (S.size()) {
        dfs(A, S, ans);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    vector<vector<int>> A(N, vector<int>(M));
    rep(i, 0, N) rep(j, 0, M) {
        cin >> A[i][j];
        --A[i][j];
    }
    int ans = INF;
    set<int> S;
    rep(i, 0, M) {
        S.insert(i);
    }
    dfs(A, S, ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter};
use std::io::*;
use std::ops::*;
use std::*;

// -----------------------------------------------
// Framework
// -----------------------------------------------

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($arg:expr),*) => {
        #[cfg(debug_assertions)]
        {
            let entries = [$(&stringify!([$arg]:), &$arg as &Debug),*];
            stderr().write_fmt(format_args!("{:#?}\n", entries)).unwrap();
        }
    };
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

// -----------------------------------------------
// Solution
// -----------------------------------------------

pub fn main() {
    let (N, M) = read!(usize, usize);
    let A = read![usize, usize; M];

    let mut S = vec![(false, 1); N];
    S[0] = (true, 1);

    for &(x, y) in A.iter() {
        let xc = S[x - 1];
        let yc = S[y - 1];

        if xc.1 >= 1 {
            S[x - 1] = (xc.0 && xc.1 - 1 > 0, xc.1 - 1);
            S[y - 1] = (xc.0 || yc.0, yc.1 + 1);
        }
    }

    let k = S.into_iter().filter(|&(r, b)| r && b >= 1).count();
    println!("{}", k);
    return;
}


Measured memory_bytes: 6524
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> hs(n);
    for (int i = 0; i < n; ++i) {
        cin >> hs[i];
    }
    vector<int> dp(n, numeric_limits<int>::max());
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        if (i + 1 < n) {
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(hs[i + 1] - hs[i]));
        }
        if (i + 2 < n) {
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i + 2] - hs[i]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1024
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) begin(V), end(V)
#define ALLR(V) rbegin(V), rend(V)
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec

#ifdef DEBUGGING
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

using namespace std;

using namespace std;
int main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    while (N) {
        ans++;
        N /= K;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N,M,C = map(int, input().split())
B = np.array(list(map(int, input().split())))
count = 0
for _ in range(N):
    A = np.array(list(map(int, input().split())))
    if np.dot(A,B) + C > 0:
        count += 1
print(count)

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}


ll col;
ll result=1;
vector<vector<ll>> a(100001);//隣接リスト(添え字は始点、値は終点)
vector<ll>t(100001);//訪問したかどうか
//場所と距離1の子と場合の数
void dfs(ll k,ll k2,ll num){
  t[k]=1;
  ll mulbuf=num;
  if(col>k2+1&&k!=0)qmod(mulbuf,col-k2-1);
  else if(k==0)mulbuf=col;
  else mulbuf=0;
  //cout<<k spa k2 spa num spa mulbuf<<endl;
  ll sumbuf1=1;//距離1の子
  for(ll i=0;i<a[k].size();i++){
    if(t[a[k][i]]==0){
      if(sumbuf1==1){
        if(k==0)dfs(a[k][i],sumbuf1-1,mulbuf); 
        else dfs(a[k][i],sumbuf1,mulbuf); 
      }
      else{
        if(k==0)dfs(a[k][i],sumbuf1-1,1); 
        else dfs(a[k][i],sumbuf1,1); 
      }
      sumbuf1++;
    }
  }
  if(sumbuf1==1&&k!=0)qmod(result,mulbuf);
  else if(sumbuf1==1&&k==0)qmod(result,mulbuf);
}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  ll n;cin>>n>>col;
  for(i=0;i<n-1;i++){
    ll p,q;
    cin>>p>>q;
    a[p-1].push_back(q-1);
    a[q-1].push_back(p-1);
  }
  dfs(0,0,1);
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 9984
/*
Problem A: Calling Extraterrestrial Intelligence Again
https://onlinejudge.u-aizu.ac.jp/problems/1232

4 < m < 100000 and 1 ≤ a ≤ b ≤ 1000.

Sample Input
5 1 2
99999 999 999
1680 5 16
1970 1 1
2002 4 11
0 0 0

Output for the Sample Input
2 2
313 313
23 73
43 43
37 53
*/
#include<iostream>
#include <array>
#include <cmath>
#include <limits>

std::array<bool, 200001> prime_list(int n){
  std::array<bool, 200001> is_prime = {};
  for(int i=0; i<200001; i++) is_prime[i] = true;
  
  is_prime[0] = false;
  is_prime[1] = false;
  
  for(int i=2; i <= std::sqrt(n)+1 ; i++){
    if(!is_prime[i]){
      continue;
    }
    for(int j=i+i; j<n+1; j=j+i){
      is_prime[j] = false;
    }
  }
  return is_prime;
}

void solve(int m, int a, int b, std::array<bool, 200001> primes){
  int max = 0;
  int p = 0; int q = 0;

  for(int i=1; i*i<=m; i++){
    for(int j=i; j<=b*i/a; j++){
      if(j<=100001){
        //std::cout << i << " " << primes[i] << " " << j << primes[j] << std::endl;
        if (primes[i]*primes[j]==1 && max < i*j && i*j <=m){
          p = i; q = j;
          max = i*j;
        }
      }
    }
  }
  std::cout << p << " " << q << std::endl;
  return;
}

int main(){

    std::array<bool, 200001> primes = prime_list(200001);
    while(1){
      int m, a, b;
      std::cin >> m >> a >>b;
      if(m+a+b == 0){
        break;
      }
      solve(m, a, b, primes);
    }
  return 0;
}



Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    ll X, K, D; cin >> X >> K >> D;
    if (abs(X)/D <= K) {
        if ((K-abs(X)/D)%2 == 0) cout << abs(X)%D << endl;
        else cout << D - abs(X)%D << endl;
    }
    else cout << abs(abs(X) - K*D) << endl;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<cctype>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;


int main () {
  char ch;

  while (1) {
    scanf("%c", &ch);

    if (ch == '\n') {
      break;
    } else if (islower(ch)) {
      printf("%c", toupper(ch));
    } else {
      printf("%c", tolower(ch));
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 940
// AOJ Namo..Cut

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

// find loop
// If the two specified nodes are on the loop, return 2
// Otherwise, return 1
int main() {
    int N;
    cin >> N;
    vector<int> table[N];
    for (int i = 0; i < N; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        table[s].push_back(t);
        table[t].push_back(s);
    }

    vector<int> dim(N);
    queue<int> que;
    for (int i = 0; i < N; i++) {
        dim[i] = table[i].size();
        if (dim[i] == 1) {
            que.push(i);
        }
    }

    vector<int> deleted(N, false);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        deleted[v] = true;
        for (int next : table[v]) {
            dim[next]--;
            if (dim[next] == 1) que.push(next);
        }
    }

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        if (!deleted[s] && !deleted[t]) {
            cout << 2 << endl;
        } else {
            cout << 1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 9208
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int top, S[1000];

void push(int x){
    top++;
    S[top] = x;
}
int pop(){
    top--;
    return S[top+1];
}

int stoi(string str){
int ret;
stringstream ss;
ss << str;
ss >> ret;
return ret;
}

int main(){
    int a, b;
    top=0;
    string s;
    while(cin >> s){
        if(s == "+"){
            a = pop();
            b = pop();
            push(a+b);
        }
        else if(s == "-"){
            b = pop();
            a = pop();
            push(a-b);
        }
        else if(s == "*"){
            a = pop();
            b = pop();
            push(a*b);
        }
        else    push(stoi(s));
    }
    cout << pop() << endl;
    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  ll x, sum = 0, a[105] = {};
  cin >> n >> x;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }
  if(sum == x){
    cout << n << endl;
  }else{
    sum = 0;
    int cnt = 0;
    sort(a, a + n);
    for(int i = 0; i < n; i++){
      x -= a[i];
      if(x >= 0) cnt++;
    }
    cout << (cnt == n ? cnt - 1 : cnt) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
N = int(input())

L = [-1] * 100
L[0] = 2
L[1] = 1
for i in range(2, 100):
    L[i] = L[i - 1] + L[i - 2]

# print('L', L)
print(L[N])


Measured memory_bytes: 2940
package main

import "fmt"

func main() {
        var s string
        fmt.Scanf("%s", &s)

        week := map[string]int{
                "SUN": 0,
                "MON": 1,
                "TUE": 2,
                "WED": 3,
                "THU": 4,
                "FRI": 5,
                "SAT": 6,
        }

        fmt.Println(7 - week[s])
}

Measured memory_bytes: 512
import sys
from scipy.misc import comb
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
nl = lambda: list(map(int, stdin.readline().split()))

n,a,b = na()
mod = 10**9 + 7
s = pow(2,n,mod) - 1
 
def fur(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod
 
print((s - fur(n,a) - fur(n,b)) % mod)

Measured memory_bytes: 14268
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////




ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}
#define N 2000004
ll kai[N];
ll kai2[N];
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n==0)return 1;
    return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}

int main(){fastio
    calc();
    ll h,w,a,b;cin>>h>>w>>a>>b;
    ll py=a+w-b;
    ll ans=0;
    if(py<=h){
        rep(i,b+1,w){
            ll r1=comb(h-a-1+b,h-a-1-(i-(b+1)));
            ll r2=comb(a+w-b-1,a+i-(b+1));
            Add(ans,r1*r2);
        }
    }else{
        rep(i,a+1,h){
            ll r1=comb(h-a-1+b,b+i-(a+1));
            ll r2=comb(a+w-b-1,i-1);
            Add(ans,r1*r2);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 31488
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll dp[1000][1000];
int solve() 
{
	//happy coding

		
	int n,m;
	cin>>n>>m;
	ll a[n+1],b[n+1];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	ll dp[n+1][m+1];
	memset(dp,0,sizeof dp);

	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(j<a[i-1]) dp[i][j] = dp[i-1][j];
			else {
				//cout<<dp[i-1][j-a[i-1]]+b[i-1]<<endl;
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-a[i-1]]+b[i-1]);
			}
		}
	}
	/*for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			cout<<dp[i][j]<<" ";
		}cout<<endl;
	}*/
	cout<<dp[n][m]<<endl;

	return 0;
}
int main(){
	int test = 1;
	//scanf("%d", &test);
	while (test--)solve();return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
using ld = long double;
ld l[301][301][301];
int main()
{
    int N;
    std::cin >> N;
    std::vector<int> num(4, 0);
    for (int i = 0, a; i < N; i++) { std::cin >> a, num[a]++; }
    auto dp = [&](auto&& self, const int one, const int two, const int three) -> ld {
        if (one == 0 and two == 0 and three == 0) { return 0; }
        if (l[one][two][three]) { return l[one][two][three]; }
        ld sum = (ld)(N - one - two - three) / N;
        if (one) { sum += (self(self, one - 1, two, three) + 1) * one / N; }
        if (two) { sum += (self(self, one + 1, two - 1, three) + 1) * two / N; }
        if (three) { sum += (self(self, one, two + 1, three - 1) + 1) * three / N; }
        return l[one][two][three] = sum * N / (one + two + three);
    };
    std::cout << std::fixed << std::setprecision(15) << dp(dp, num[1], num[2], num[3]) << std::endl;
    return 0;
}


Measured memory_bytes: 426240