akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    ll N;
    cin >> N;
    array<ll, 5> a;
    rep(i, 0, 5) cin >> a[i];
    array<ll, 5> times;

    times[0] = (N + (a[0] - 1)) / a[0];

    rep(i, 1, 5)
    {
        if (a[i] >= a[i - 1])
        {
            times[i] = times[i - 1] + 1;
        }
        else
        {
            times[i] = max(times[i - 1] + 1, i + (N + (a[i] - 1)) / a[i]);
        }
    }

    cout << times[4] << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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;}

string s;

int main(){
    cin >> s;
    int n = s.size();
    int red=0,blue=0;
    REP(i,n){
        if(s[i]=='0')red++;
        else blue++;
    }
    put(min(red,blue)*2);
    return 0;
}


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

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if((a == b) && (b == c)) {
	    cout << 1 << endl;
	} else if ((a == b) || (b == c) || (c == a)) {
	    cout << 2 << endl;
	} else {
	    cout << 3 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> bit(65, 0);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        int c = 0;
        while(a[i]) {
            bit[c] += (a[i] & 1);
            c++;
            a[i] = (a[i] >> 1);
        }
    }
    ll k = 1;
    ll ans = 0;
    for(int i = 0; i < 65; i++) {
        ll tmp = bit[i] * (n - bit[i]);
        tmp %= MOD;
        ans += tmp * k;
        ans %= MOD;
        k *= 2;
        k %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
X,N = list(map(int,input().split()))
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    for i in range(100):
        if not X - i in P:
            a = X - i
            break
        if not X + i in P:
            a = X + i
            break
    print(a)

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

int main() {
 int n,k; cin >> n >> k;
vector<bool> snuke(n,0);
 for(int i=0;i<k;i++){
  int d; cin >> d;
   for(int j=0;j<d;j++){
     int A; cin >>A;
     snuke[A-1]=1;
   }
 }
 int cnt=0;
 for(int i=0;i<n;i++){
   if(!snuke[i])cnt++;
 }
 cout << cnt << endl;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		
		int A = scan.nextInt();
		int B = scan.nextInt();
		
		if (A < 10 && B < 10) {
			System.out.println(A * B);
		} else {
			System.out.println(-1);
		}
		
		
	}
}


Measured memory_bytes: 23764
h,w,K = map(int,input().split())
s = [[int(i) for i in list(input())] for _ in range(h)]

ssum = [[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if i == 0:
      ssum[i][j] = s[i][j]
    else:
      ssum[i][j] = ssum[i-1][j] + s[i][j]

def cnt(line,i,j):
  if i == 0:
    return ssum[j-1][line]
  else:
    return ssum[j-1][line] - ssum[i-1][line]

ans = 10**6
for i in range(2**(h-1)):
  l = [0]
  s = 0
  for j in range(h):
    if i >> j & 1:
      s += 1
      l.append(j+1)
  l.append(h)
  d = [0]*(len(l)-1)
  for j in range(w):
    nxt = [cnt(j,l[k],l[k+1]) for k in range(len(l)-1)]
    d2 = [nxt[i]+d[i] for i in range(len(l)-1)]
    if max(nxt) > K:
      s = 10**7
      break
    if max(d2) > K:
      d = nxt
      s += 1
    else:
      d = d2
  ans = min(ans,s)
print(ans)

Measured memory_bytes: 46044
def Main(S):
    N = len(S)
    r_S = S[::-1]
    A = S[:(N-1)//2]
    r_A = A[::-1]
    B = S[(N+1)//2:]
    r_B = B[::-1]
    return "Yes" if S == r_S and A == r_A and B == r_B else "No"
    

def main():
    S = str(input())
    print(Main(S))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import Control.Monad
import Data.Array.IArray
import Data.Bits
import Data.Bool

import Debug.Trace
_t x = traceShow x x

bit2List :: Int -> Int -> [Int]
bit2List b n = go 0
  where
    go i | i  == n   = []
         | bi /= 0   = i : go (i+1)
         | otherwise = go (i+1)
      where bi = b .&. shift 1 i

solve :: Array Int [(Int,Int)] -> Int
solve a = maximum $ go1 (0 :: Int)
  where
    n = length a
    go1 b | b == shift 1 n = []
          | otherwise = go2 b : go1 (b+1)
    go2 b = let lb = bit2List b n
             in bool 0 (length lb) $ all f lb
      where
        f i = all g (a!i)
        g (x,y) = let p = b .&. shift 1 (x-1)
                   in ((y == 1 && p /= 0) || (y == 0 && p == 0))

main :: IO ()
main = do
    n <- readLn :: IO Int
    xy <- replicateM n $ do
        a <- readLn :: IO Int
        replicateM a $ do
            [x,y] <- map read . words <$> getLine :: IO [Int]
            return (x,y)
    let xy' = listArray (0,n-1) xy :: Array Int [(Int,Int)]
    print $ solve xy'

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

int main() {
    int N, X, Y;
    cin >> N >> X >> Y;
    int cnt[N] = {};
    for (int i = 1; i < N; i++) {
        for (int j = i + 1; j <= N; j++) {
            int cur = min(j - i, abs(X - i) + abs(Y - j) + 1);
            cnt[cur]++;
        }
    }
    for (int i = 1; i < N; i++) {
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int cnt = 0;
	char cf2016[] = "CODEFESTIVAL2016";
	char s[20];
	scanf("%s",s);
	for (int i = 0; i < strlen(cf2016); ++i)
	{
		if(cf2016[i] != s[i])	++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    vector<char> c(2*N);
    vec a(2*N);
    vec white(N), black(N);

    Rep (i, 2*N) {
        cin >> c[i] >> a[i];
        a[i]--;
        if (c[i] == 'W') white[a[i]] = i;
        else black[a[i]] = i;
    }
    white.push_back(2*N);
    black.push_back(2*N);

    // Rep (i, N) {
    //     cout << white[i] << "\n";
    // }


    // Rep (i, N) {
    //     cout << black[i] << "\n";
    // }

    mat sw(2*N+1, vec(N+1, 0)), sb(2*N+1, vec(N+1, 0));
    Rep (i, 2*N) {
        Rep (j, N) {
            sw[i+1][j] += sw[i][j];
            sb[i+1][j] += sb[i][j];
        }
        if (c[i] == 'B') {
            Rep (j, a[i]+1) {
                sb[i+1][j]++;
            }
        } else {
            Rep (j, a[i]+1) {
                sw[i+1][j]++;
            }
        }
    }

    // Rep (i, 2*N+1) {
    //     Rep (j, N+1) {
    //         cout << sw[i][j] << " \n"[j==N];
    //     }
    // }

    mat dp(N+1, vec(N+1, inf));
    dp[0][0] = 0;

    Rep (i, N+1) {
        Rep (j, N+1) {
            if (i < N) chmin(dp[i+1][j], dp[i][j] + sw[white[i]][i] + sb[white[i]][j]);
            if (j < N) chmin(dp[i][j+1], dp[i][j] + sw[black[j]][i] + sb[black[j]][j]);

            // cout << i << " " << j << "\n";
            // if (i+1 < N) chmin(dp[i+1][j], dp[i][j]);
            // if (j+1 < N) chmin(dp[i][j+1], dp[i][j]);
        }
    }

    // Rep (i, N+1) {
    //     Rep (j, N+1) {
    //         cout << dp[i][j] << " \n"[j==N];
    //     }
    // }

    cout << dp[N][N] << endl;
}

Measured memory_bytes: 157056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=500+5;
const int N=3000+5;
const ll oo=1e18+5;
const ll mod=998244353;

ll mul(ll a,ll b){
	return a*b%mod;
}

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

void add_self(ll& a,ll b){
	a+=b;
	if(a>=mod) a-=mod;
}

int n,s;
ll dp[N];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>s;
	vector<ll> a(n);
	for(ll& x:a) cin>>x;
	ll inv2=poww(2,mod-2);
	dp[0]=poww(2,n);
	for(int i=0;i<n;++i){
		for(int sum=s;sum>=a[i];--sum){
			add_self(dp[sum],mul(dp[sum-a[i]],inv2));
		}
	}
	cout<<dp[s];
	return 0;
}


Measured memory_bytes: 3704
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import fractions
from functools import reduce
N = int(input())
A = [int(i) for i in input().split()]



L = [0 for i in range(N)]
R = [0 for i in range(N)]
L[0] = A[0]
R[-1] = A[-1]
for i in range(N-1):
    L[i+1] = fractions.gcd(L[i],A[i+1])

for j in reversed(range(N-1)):
    R[j] = fractions.gcd(A[j],R[j+1])

L.append(0)
L.insert(0,0)
R.append(0)
R.insert(0,0)

ans = 1
for i in range(N):
    # print(L[i],R[i+2])
    ans = max(ans,fractions.gcd(L[i],R[i+2]))

print(ans)







"""
嘘解法
def gcd(nums):
    return reduce(fractions.gcd,nums)

ans = 1
A.sort()
gcd1 = gcd(A)
for i in range(N):
    A[i] //= gcd1

ans *= gcd1

gcd2 = A[0]
for i in range(1,N):
    gcd2 = fractions.gcd(gcd2,A[i])
    if gcd2 == 1:
        key = i
        break

a = copy.deepcopy(A)
a.remove(A[0])
b = copy.deepcopy(A)
b.remove(A[key])

ans *= max(gcd(a),gcd(b))
print(ans)
"""


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

int main() {
  long long int N;
  string S;
  cin >> N >> S;
  vector<long long int> R, G;
  set<long long int> B;
  for (long long int i = 0; i < N; i++) {
    if (S.at(i) == 'R') R.push_back(i);
    else if (S.at(i) == 'G') G.push_back(i);
    else B.insert(i);
  }
  long long int r = R.size(), g = G.size(), b = B.size();
  long long int ans = r * g * b;
  for (long long int i = 0; i < r; i++) {
    for (long long int j = 0; j < g; j++) {
      if ((R.at(i) + G.at(j)) % 2 == 0 && B.count((R.at(i) + G.at(j)) / 2)) ans--;
      if (B.count(2 * R.at(i) - G.at(j))) ans--;
      if (B.count(2 * G.at(j) - R.at(i))) ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3740
while True:
    m,f,r = map(int,input().split(' '))
    result = m + f
    if (m + f + r) == -3:
        break
    if m == -1 or f == -1 or result < 30:
        print('F')
        continue
    if result >= 80:
        print('A')
        continue
    if result >= 65:
        print('B')
        continue
    if result >= 50 or (result >= 30 and r >= 50):
        print('C')
        continue
    if result >= 30:
        print('D')
        continue
    


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

int main(){
	int n, k;
  	cin >> n >> k;
  	vector<int> A(n+1, 0);
  
  	rep(i, k){
    	int d;
      	cin >> d;
      	rep(j, d){
          	int a;
        	cin >> a;
          	A[a]++;
        }
    }
  	
  	int ans = 0;
  	for(int i = 1; i < n+1; i++) if(A[i] == 0) ans++;
 	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    int N, M, tmp, _max = 0, count = 0;
    long long result = 1;
    //入力
    scanf("%d%d", &N, &M);
    vector<int> A(N , 1);
    vector <int> q;

    for(int i = 0; i < M; i ++){
        scanf("%d", &tmp);
        A[tmp - 1] = 0;
    }

    //キューに階段の塊の数をpush
    for(const auto &e : A){
        if(e == 0){
            if(count == -1){
                cout << 0 << endl;
                return 0;
            }
            else{
                q.push_back(max(count, 1));
                count = -1;
            }
        }
        else{
            count ++;
        }
    }
    if(count > 0){
        q.push_back(count);
        count = -1;
    }

    //一番大きい階段の塊を_maxに代入
    sort(q.begin(), q.end());
    _max = q.back();

    //フィボナッチ数列の計算
    vector <long long> fibonacci(_max);
    fibonacci[0] = 1;
    fibonacci[1] = 2;
    for(int i = 2; i < _max; i++)
        fibonacci[i] = (fibonacci[i - 1] + fibonacci[i - 2]) % 1000000007;

    //結果の計算
    for(const auto &e: q)
        result = result * fibonacci[e - 1] % 1000000007;


    cout << result << endl;
    return 0;
}

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


int main(){
  int N,W;
  cin >> N >> W;
  vector<int> w(N,W),v(N,1000000000);
  for(int i=0;i<N;i++){
    cin >> w.at(i) >> v.at(i);
  }
  vector<vector<long long>> dp(N+1,vector<long long> (W+1));
  for(int i=0;i<N;i++){
    for(int j=0;j<W+1;j++){
      if(j>=w.at(i)){
        dp.at(i+1).at(j)=max(dp.at(i).at(j),dp.at(i).at(j-w.at(i))+v.at(i));
      }
      else{
        dp.at(i+1).at(j)=dp.at(i).at(j);
      }
    }
  }
  cout << dp.at(N).at(W) << endl;
}

Measured memory_bytes: 83080
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int dignum(ll n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int main(){

  ll N;
  cin >> N;

  int ans = dignum(N); // 最大の桁数を求めて億

  for (ll A = 1; A*A <= N; A++) { // Aを1からNまで、A*Aつまり√Aで求める。Nが100ならAは1〜10になる
    if(N%A != 0) continue; // NがAで割り切れない場合は飛ばす
    ll B = N/A;

    int cur = max(dignum(A), dignum(B)); // 関数F（AとBの大きい桁数を保存する)

    ans = min(ans, cur); // 最小の値を求める
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3596
#include <vector>
#include <cstdio>
#include <cmath>
#include <complex>
#include <cfloat>
using namespace std;

typedef double D;
typedef complex<D> P;
typedef const P &rP;
typedef pair<P,P> seg;
typedef const seg &rseg;

#define EPS 1e-9
#define INF DBL_MAX

inline D cross(rP a, rP b){
	return real(a) * imag(b) - imag(a) * real(b);
}

inline D dot(rP a, rP b){
	return real(a) * real(b) + imag(a) * imag(b);
}

P crosspoint(rseg sa, rseg sb){
	rP pa1 = sa.first, pa2 = sa.second, pb1 = sb.first, pb2 = sb.second;
	P da12 = pa2 - pa1;
	P db21 = pb1 - pb2;
	P dab1 = pb1 - pa1;
	D d = cross(da12, db21);
	if(abs(d) > EPS){
		D t = cross(dab1, db21) / d;
		return pa1 + t * (pa2 - pa1);
	}
	return P(INF, INF);
}

vector<P> intrCC(rP p1, D r1, rP p2, D r2){
	D d = abs(p2 - p1);
	D phi = arg(p2 - p1);
	vector<P> ret;
	D ct = (d * d + r1 * r1 - r2 * r2) / (2.0 * d * r1);
	if(ct > 1.0 && ct < 1.0 + EPS){
		ct = 1.0;
	}
	else if(ct < -1.0 && ct > -1.0 - EPS){
		ct = -1.0;
	}
	if(abs(ct) > 1.0){ return ret; }
	D theta = acos(ct);
	
	ret.resize(2);
	ret[0] = p1 + polar(r1, phi + theta);
	ret[1] = p1 + polar(r1, phi - theta);
	return ret;
}


vector<P> ps;
vector<D> ls;
vector<seg> segs;
D ans;

void check(rP z){
	D r = INF;
	for(int i = 0; i < ps.size(); ++i){
		r = min(r, ls[i] * ls[i] - norm(ps[i] - z));
	}
	ans = max(ans, sqrt(r));
}


int main(){
	int n;
	while(scanf("%d", &n), n){
		ps.resize(n);
		ls.resize(n);
		D x, y;
		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf", &x, &y, &ls[i]);
			ps[i] = P(x, y);
		}

		segs.clear();
		ans = 0.0;
		for(int i = 0; i < n; ++i){
			check(ps[i]);
			for(int j = 0; j < i; ++j){
				vector<P> w = intrCC(ps[i], ls[i], ps[j], ls[j]);
				if(w.empty()){ continue; }
				segs.push_back(seg(w[0], w[1]));
				check(0.5 * (w[0] + w[1]));
			}
		}
		
		for(int i = 0; i < segs.size(); ++i)
		for(int j = 0; j < i; ++j){
			P z = crosspoint(segs[i], segs[j]);
			if(real(z) != INF){
				check(z);
			}
		}
		printf("%.9f\n", ans);
	}
}

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

const double PI = acos(-1);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

// nCr
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// usage:
//   combination comb(n+5);
//   ans = comb(n,r);
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

// 階乗
mint factorial(ll k) {
	mint sum = 1;
	for (mint i = 1; i.x <= k; i = i + 1)
	{
		sum *= i;
	}
	return sum;
}

void solve_abc_c() {
	ll n, m;
	ll a, b;
	//ll ans = 0;
	//double ans = 0;
	
	cin >> n >> m;

	mint ans;
	mint tmp = 2;

	if (abs(n - m) > 1) {
		ans = 0;
	}
	else {
		if (n == m) {
			ans = factorial(n) * factorial(n) * tmp;
		}
		else {
			ans = factorial(max(m, n)) * factorial(min(m, n));
		}
	}

	cout << ans.x << "\n";
}

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

	solve_abc_c();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

class sorter{
  int cnt;
public:
  void shellSort(int *array, int num);
private:
  void insertionSort(int *array, int num, int g);
};

void sorter::insertionSort(int *array,int num, int g){
  for (int i = g; i < num; i++) {
    int v = array[i];
    int j = i -  g;
    while (j >= 0 && array[j] > v) {
      array[j + g] = array[j];
      j -= g;
      cnt++;
    }
    array[j + g] = v;
  }
}

void sorter::shellSort(int *array, int num){
  int h = 1;
  int m = 0;

  for (int h_tmp = 1; h_tmp < num/* "/ 9" */; h_tmp = h_tmp * 3 + 1){
    h = h_tmp;
    m++;
  }
  if (h == 1) m = 1;
  cout /*<< "m = "*/ << m << endl;
  for(int h_tmp = h; h_tmp > 0; h_tmp /= 3){
    cout /*<< "h_tmp = "*/ << h_tmp;
    if(h_tmp == 1){
      cout << endl;
    }else{
      cout << " ";
    }
  }
  cnt = 0;
  while( h > 0){
    insertionSort(array, num, h);
    h /= 3;
  }
  cout /*<< "cnt = "*/ << cnt << endl;
}


int main(int argc, char const *argv[]) {
  int num;
  cin >> num;
  int *array = new int[num];
  for(int i = 0; i < num; i++){
    cin >> array[i];
  }
  sorter s;
  s.shellSort(array, num);
  for(int i = 0; i < num; i++){
    cout << array[i] << endl;
  }
  delete [] array;
  return 0;
}

Measured memory_bytes: 6716
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int par[100005],Rank[100005];
void init(int n){
    for(int i=1;i<=n;i++){
        par[i]=i; Rank[i]=0;
    }
}
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}
void unite(int x,int y){
    x=find(x); y=find(y);
    if(x==y) return;
    if(Rank[x]<Rank[y]){
        par[x]=y;
    }else{
        par[y]=x;
        if(Rank[x]==Rank[y]) Rank[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}
int main(void){
	int n,m; cin>>n>>m;
	init(n);
	int ans=1;
	int a,b,c;
	for(int i=0;i<m;i++){
		cin>>a>>b>>c;
		unite(a,b);
	}
	for(int i=2;i<=n;i++){
		if(!same(1,i)){
			ans++;
			unite(1,i);
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }

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

	int n;
	cin >> n;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	bool zero = false;
	rep(i, n) if(a[i] == 0) zero = true;

	if(zero){
		cout << 0 << endl;
		exit(0);
	}

	ll prod = 1ll;
	rep(i, n){
		if(a[i] > (ll) 1e18 / prod){
			cout << -1 << endl;
			exit(0);
		}

		prod *= a[i];
	}

	cout << prod << endl;
}


Measured memory_bytes: 4440
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();

    let mut cnt = 0;
    for _ in 0..n {
        let x:u32 = read();
        if is_prime(x) {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}

fn is_prime(x: u32) -> bool {
    match x {
        x if x == 2 => true,
        x if x < 2 || x % 2 == 0 => false,
        _ => {
            let mut i = 3;
            while i * i <= x {
                if x % i == 0 {
                    return false;
                }
                i += 2;
            }
            true
        }
    }
}


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

using namespace std;
inline int abs(int a, int b){
    if(a > b) return a - b;
    return b - a;
}
int FrogDP(int* a, int n){    //assume a is indexed from 1 
    
    int* ans = new int[n+1]; //a[i] denotes the answer for i heights
    ans[1] = 0; ans[2] = abs(a[1], a[2]);
    
    for(int i = 3; i<=n; i++){
        int option1 = abs(a[i], a[i-1]) + ans[i-1];
        int option2 = abs(a[i], a[i-2]) + ans[i-2];
        ans[i] = min(option2, option1);
    }
    
    return ans[n];
}


int main() {
    int n, a[100002];
    cin >> n;
    for(int i = 1; i<=n; i++) cin >> a[i];
    cout << FrogDP(a, n) << endl;
}
    

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

int main(void) {
    const string result[3] = {"dangerous", "safe", "delicious"};
    int x, a, b, taste = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> a >> b;
    if (x < b - a) {
        taste = 0;
    } else if (0 < b - a) {
        taste = 1;
    } else if (b - a < x) {
        taste = 2;
    }

    cout << result[taste] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define MP(a, b) make_pair((a), (b))
#define Y first
#define X second
#define C first
#define W second
#define INF 1 << 30

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

int w, h;
int d[7][7];
int dx[] = {0,-1,0,1}, dy[] = {-1,0,1,0};
map<pi, bool>wm;

int check(int ay, int ax, int by, int bx, int cy, int cx){
  //  printf("%d %d %d %d\n", ay, ax, by, bx);
  if(ay == by && ax == bx) return 1;
  //  printf("%d %d %d %d\n", ay, ax, by, bx);
  int res = 0;
  rep(i, 4){
    int ny = ay+dy[i], nx = ax+dx[i];
    if(ny < 0 || nx < 0 || ny >= h || nx >= w || d[ny][nx] == 1 ||  wm.count(MP(ny, nx)) ||
       (ny == cy && nx == cx)) continue;
    wm[MP(ny, nx)] = 1;
    res += check(ny, nx, by, bx, cy, cx);
    //     wm.erase(MP(ny, nx));
  }
  return res;
}

int main(){
  while(scanf("%d%d", &w, &h) && w+h){
    int y, x, wy, wx;
    rep(i, h) rep(j, w){
      scanf("%d", &d[i][j]);
      if(d[i][j] == 2){ y = i, x = j; d[i][j] = 0;}
      if(d[i][j] == 4){ wy = i, wx = j; d[i][j] = 0;}
    }

    queue<pair<pi, pi> >q;
    map<pair<pi, pi>, bool>m;
    q.push(MP(MP(y, x), MP(wy, wx)));
    m[MP(MP(y, x), MP(wy, wx))] = 1;

    int res = 1;
    while(!q.empty()){
      //  printf("%d\n", res);
      int qsize = (int)q.size();
      rep(i, qsize){
	pair<pi, pi> now = q.front(); q.pop();
	rep(j, 4){
	  //	  printf("j %d\n", j);
	  int ny = now.C.Y + dy[j], nx = now.C.X + dx[j];
	  int nwy = now.C.Y + dy[(j+2)%4], nwx = now.C.X + dx[(j+2)%4];
	  //  printf("next %d %d %d %d\n", ny, nx, nwy, nwx);
	  wm.clear();
	  wm[MP(now.W.Y, now.W.X)] = 1;
	  if(ny < 0 || nx < 0 || ny >= h || nx >= w ||
	     nwy < 0 || nwx < 0 || nwy >= h || nwx >= w ||
	     d[ny][nx] == 1 || d[nwy][nwx] == 1 || 
	     m.count(MP(MP(ny, nx), MP(nwy, nwx))) || !check(now.W.Y, now.W.X, nwy, nwx, now.C.Y, now.C.X)) continue;

	  if(d[ny][nx] == 3){
	    printf("%d\n", res);
	    goto e;
	  }
	  //	  printf("%d %d %d %d\n", ny, nx, nwy, nwx);
	  q.push(MP(MP(ny, nx), MP(nwy, nwx)));
	  m[MP(MP(ny, nx), MP(nwy, nwx))] = 1;
	}
      }
      res++;
    }
    puts("-1");
  e:;
  }
  return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<pair<pair<string, int>, int> > A(N);
    rep(i, N)
    {
        string S;
        int a;
        cin >> S >> a;
        a *= -1;
        A[i] = make_pair(make_pair(S, a), i + 1);
    }
    sort(A.begin(), A.end());
    rep(i, N)
    {
        cout << A[i].second << endl;
    }
}


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

using namespace std;

using ll = long long;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
    cin.tie(0);
    cout << fixed << setprecision(10);

    int d; cin >> d;
    string c = "Christmas", s = "Eve";
    if(d == 25) {
      cout << c << endl;
    } else if(d == 24) {
      cout << c << " " << s << endl;
    } else if(d == 23) {
      cout << c <<" " <<  s << " " <<  s << endl;
    } else {
      cout << c <<  " " << s << " " << s << " " << s << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
ll goingIn[100010], goingOut[100010];
bool done[100010];
vector<pair<int, ll> > inadj[100010], adj[100010], revadj[100010];
int n, m, s, t;
ll d[100010];
ll pathsAfter(ll a)
{
	if (done[a]) return goingOut[a];
	done[a] = true;
	if (a == t) return goingOut[a] = 1;
	ll ans = 0;
	for (auto b : adj[a]) 
	{
		ans += pathsAfter(b.first);
	}
	return goingOut[a] = ans%mod;
}
ll pathsBefore(ll a)
{
	if (done[a]) return goingIn[a];
	done[a] = true;
	if (a == s) return goingIn[a] = 1;
	ll ans = 0;
	for (auto b : revadj[a]) 
	{
		ans += pathsBefore(b.first);
	}
	return goingIn[a] = ans%mod;
}
ll ans;
void findAns(int a, ll d, ll dis, ll total) // dis so far, total dis, total paths
{
	if (done[a]) return;
	done[a] = true;
//	printf("at %d\n", a);
	if (!(dis % 2) && dis/2 == d)
	{
		// this point is half way

		ll am = (goingIn[a] * goingOut[a])%mod;
		am *= am;
		ans -= (am)%mod;
		return;
	}
	for (auto b: adj[a])
	{
		ll d1 = dis/2;
		ll d2 = d1 + dis % 2;
		if (d < d2 && d + b.second > d1)
		{
		//	printf("%d -> %d, %d\n", a, b.first, b.second);
			ll am = (goingIn[a] * goingOut[b.first])%mod;
			am *= am;
			ans -= (am)%mod;
		}
		else findAns(b.first, d + b.second, dis, total);
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	scanf("%d%d", &s, &t);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		int c;
		scanf("%d%d%d", &a, &b, &c);
		inadj[a].emplace_back(b, c);
		inadj[b].emplace_back(a, c);
	}
	fill_n(d, 100010, 999999999999999);
	d[s] = 0;
	priority_queue<pair<int, ll> > pq;
	pq.emplace(s, 0);
	while (!pq.empty())
	{
		int a;
		ll dis;
		a = pq.top().first;
		dis = -pq.top().second;
		pq.pop();
		if (d[a] != dis) continue;
		for (auto b : inadj[a])
		{
			if (d[b.first] > dis + b.second)
			{
				revadj[b.first].clear();
				d[b.first] = dis + b.second;
				pq.emplace(b.first, -d[b.first]);
			}
			if (d[b.first] == dis + b.second)
			{
				revadj[b.first].emplace_back(a, b.second);
			}
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (auto b : revadj[i])
		{
			adj[b.first].emplace_back(i, b.second);
		}
	}
	pathsAfter(s);
	fill_n(done, 100010, 0);
	pathsBefore(t);
	ans = goingOut[s] * goingOut[s];
	ans %= mod;
	fill_n(done, 100010, 0);
//	printf("%lld\n", ans);
	findAns(s, 0, d[t], goingOut[s]);
	while (ans < 0)
	{
		ans += mod;
	}
	ans %= mod;
	printf("%lld\n", ans);
}

Measured memory_bytes: 55656
def gcd(m, n):
    if m < n:
        return gcd(n, m)
    elif n == 0:
        return m
    return gcd(n, m % n)

def gcd_list(lst):
    if len(lst) <= 1:
        return lst[0]
    ans = gcd(lst[0], lst[1])
    for e in lst:
        ans = gcd(ans, e)
    return ans

N, X = map(int, input().split())
x = list(map(int, input().split()))
x_adjusted = list(map(lambda x : abs(x - X), x))
print(gcd_list(x_adjusted))

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

int main() {

  int a;
  cin >> a;  
  
  vector<int> t(a);
  rep(i,a) cin >> t[i];
  
  sort(t.begin(),t.end());
  
  cout << t[a-1] - t[0] << endl;
  
}


Measured memory_bytes: 256
import itertools

N,K = map(int,input().split())
A = list(map(int,input().split()))
L = [_ for _ in range(1,N)]
ans = float("inf")
cand = list(itertools.combinations(L,K-1))
#print(cand)
for C in cand:
  C = list(C)
  C.sort()
  temp = 0
  prev = A[0] #最初のビルは必ず見える。
  #print(C)
  Flag = True
  for i in C:
    #print(prev,min(A[:i]))
    if prev < max(A[:i]):
      #print(C)
      Flag = False
      break
    if A[i] <= prev:
      prev += 1
      temp += prev-A[i]
    else:
      prev = A[i]
  if Flag:
    ans = min(ans,temp)
print(ans)

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

int main() {
  string N;
  cin >> N;
  string ans;
  if (N == "Sunny")
    ans = "Cloudy";
  else if (N == "Cloudy")
    ans = "Rainy";
  else
    ans = "Sunny";
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ll n ;
int ans=50;
void solve(ll a, ll b)
{
	int cnt1=0, cnt2=0;
	while (a)
	{
		cnt1++;
		a/=10;
	}
	while (b)
	{
		cnt2++;
		b/=10;
	}
	ans=min(ans, max(cnt1, cnt2));
}
int main()
{
	IO;
	cin>>n;
	for (ll i=1 ; i*i<=n; i++)
	{
		if (n%i)
			continue;
		solve(i, n/i);
	}
	cout<<ans;

}


Measured memory_bytes: 256
tt = [int(input()) for i in range(5)]
ll = [10*i for i in range(14)]
ans = []
at = bt = ct = dt = et = 0
for t in tt:
    i = 0
    while t > ll[i]:
        i+=1
    ans.append(ll[i])

max = 0
dex = 0
for i in range(5):
    if ans[i] - tt[i] > max:
        dex = i
        max = ans[i]-tt[i]
at = 0
for j in range(5):
    if j != dex:
        at += ans[j]
    if j == dex:
        at += tt[j]

print(at)


Measured memory_bytes: 3064
def c():
    n = int(input())
    a = list(map(int, input().split()))
    # x = []
    def set_col(rate):
        r = rate // 400
        r = min(8, r)
        return r

    l = list(map(set_col, a))
    over_rate = l.count(8)
    res = set(l)
    if 8 in res: res.remove(8)

    mi = max(1, len(res))
    ma = len(res) + over_rate
    print(mi, ma)

c()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#define rgi register int
using namespace std;
const int maxn=1e5+5;
int n,a[maxn],f1[maxn],f2[maxn],indx1,indx2,bok[maxn];
bool ans=1,book[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(rgi i=1;i<=n;++i)
    	cin>>a[i];
    for(rgi i=n;i>1;--i)
    	if(a[i-1]>a[i])
    		--a[i-1];
    f1[++indx1]=a[1];
    for(rgi i=2;i<=n;++i)
    {
        int k1=upper_bound(f1+1,f1+indx1+1,a[i])-f1;
        f1[k1]=a[i];
        if(bok[k1])
        	book[bok[k1]]=0;
        bok[k1]=i,book[i]=1;
        if(k1>indx1)
        {
            ++indx1;
        }
    }
    //cout<<indx1<<endl;
    if(indx1==n)
    {
    	cout<<"Yes"<<endl;
    	return 0;
	}
	else
	{
		cout<<"No"<<endl;
		return 0;
	}
    for(rgi i=2;i<=n;++i)
    	if(!book[i])
    		--a[i];
    f2[++indx2]=a[1];
    for(rgi i=2;i<=n;++i)
    {
     	int k2=upper_bound(f2+1,f2+indx2+1,a[i])-f2;
        f2[k2]=a[i];
        if(k2>indx2)
            ++indx2;
    }
    //cout<<indx2<<endl;
    //for(rgi i=1;i<=n;++i)
    //	cout<<a[i]<<" ";
    //cout<<endl;
    if(indx2==n)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <functional>
#include <algorithm>
#include <climits>

using namespace std;

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

struct Edge
{
	int to;
	int cost;
};

struct Node
{
	int city_index;
	int total_cost;
	int current_life;

	bool operator >(const Node &a) const
	{
		return total_cost > a.total_cost;
	}
};

int main()
{
	int city_count, initial_life, cooler_count, road_count, start_index, goal_index;
	while (cin >> city_count >> initial_life >> cooler_count >> road_count >> start_index >> goal_index,
		city_count)
	{
		// input
		vector<int> is_cooler(city_count, false);
		REP(i, cooler_count)
		{
			int cooler_index;
			cin >> cooler_index;
			is_cooler[cooler_index] = true;
		}
		vector<vector<Edge>> roads(city_count);
		REP(i, road_count)
		{
			int from, to, cost;
			cin >> from >> to >> cost;
			roads[from].push_back({ to, cost });
			roads[to].push_back({ from, cost });
		}

		// dijkstra
		vector<vector<int>> d(city_count, vector<int>(initial_life + 1, INT_MAX)); // [city_index][current_life] => total_cost
		d[start_index][initial_life] = 0;
		priority_queue<Node, vector<Node>, greater<Node> > pq;
		pq.push({ start_index, 0, initial_life });
		while (true)
		{
			if (pq.empty())
			{
				cout << "Help!" << endl;
				break;
			}
			auto current_node = pq.top(); pq.pop();
			if (current_node.city_index == goal_index)
			{
				cout << current_node.total_cost << endl;
				break;
			}
			if (is_cooler[current_node.city_index])
			{
				if (current_node.current_life < initial_life)
				{
					int life = current_node.current_life + 1;
					int cost = current_node.total_cost + 1;
					int city_index = current_node.city_index;
					if (cost < d[city_index][life])
					{
						d[city_index][life] = cost;
						pq.push({ city_index, cost, life });
					}
				}
			}
			
			for (auto &road : roads[current_node.city_index])
			{
				int life = current_node.current_life - road.cost;
				if (life < 0)
				{
					continue;
				}
				int cost = current_node.total_cost + road.cost;
				if (cost < d[road.to][life])
				{
					d[road.to][life] = cost;
					pq.push({ road.to, cost, life });
				}
			}

		}
	}

	return 0;
}

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

typedef long long int64;

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

  vector<string> s(n);

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

  sort(s.begin(),s.end());
    
  int64 cnt = 0;
  int a = 0;
  size_t size = s.size();
  string tmp = s[0];
  int64 tmp_cnt = 0;

  for(string str: s){
    if(tmp == str){
      tmp_cnt++;
    } else {
      tmp = str;
      cnt += tmp_cnt * (tmp_cnt - 1)/2;
      tmp_cnt = 1;
    } 
  }

  if(tmp_cnt){
    cnt += tmp_cnt * (tmp_cnt - 1)/2;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long cc;
static const cc MAX = 100000;

cc N, K, i, j, k, sub = 0, n = 0, X, Y, A[MAX], B[MAX];
cc judge = 0, Ans, J[MAX];
string S;
/*
vector<cc> vec1(MAX), vec2(MAX);
vector<pair<cc, cc>> pairs(MAX);
*/



int main() {	
	cin >> N >> K;
	sub = N - 1;
	Ans = K - sub;

	for (i = 0; i < N * 2 - 1; i++) {
		if (i) cout << " ";
		cout << Ans;
		Ans++;
	}
	cout << endl;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> intint;

int main(void)
{
    int a,b;
    cin >> a >> b;
    pr(a + b/2);
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
string ml[50], mr[50];
bool fm[50][50][50][50];
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };
int main() {
	int w, h;
	while (cin >> w >> h, w) {
		fill((bool*)fm, (bool*)fm + 2500 * 2500, 0);
		vector<pair<pii,pii>> que;
		pii r, l, gl, gr;
		pair<pii, pii> g;
		for (int i = 0; i < h; i++) {
			cin >> ml[i] >> mr[i];
			int a = ml[i].find('L');
			if (a != string::npos)l = make_pair(a, i);
			a = ml[i].find('%');
			if (a != string::npos)gl = make_pair(a, i);
			a = mr[i].find('R');
			if (a != string::npos)r = make_pair(a, i);
			a = mr[i].find('%');
			if (a != string::npos)gr = make_pair(a, i);
		}
		g = make_pair(gl, gr);
		que.push_back(make_pair(l, r));
		bool f = 0;
		while (!que.empty()&&!f) {
			auto top = que.back();
			que.pop_back();
			for (int i = 0; i < 4; i++) {
				auto n = top;
				n.first.first += dx[i];
				n.first.second += dy[i];
				n.second.first -= dx[i];
				n.second.second += dy[i];
				if (n.first.first < 0 || n.first.first >= w)n.first.first = top.first.first;
				if (n.first.second < 0 || n.first.second >= h)n.first.second = top.first.second;
				if (n.second.first < 0 || n.second.first >= w)n.second.first = top.second.first;
				if (n.second.second < 0 || n.second.second >= h)n.second.second = top.second.second;
				if (ml[n.first.second][n.first.first] == '#')n.first = top.first;
				if (mr[n.second.second][n.second.first] == '#')n.second = top.second;
				if (ml[n.first.second][n.first.first] == '%'&&mr[n.second.second][n.second.first] == '%') {
					f = 1;
					break;
				}
				if (ml[n.first.second][n.first.first] == '%'^mr[n.second.second][n.second.first] == '%')continue;
				bool a = 1;
				swap(fm[n.first.first][n.first.second][n.second.first][n.second.second], a);
				if (a)continue;
				que.push_back(n);
			}
		}
		cout << (f ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 41976
n = list(map(int, input().split()))[0]
s = [i for i in range(n)]
a = tuple(map(int, input().split()))
b = 0
for i in a:
    if i % 2:
        b = (b - i) % len(s)
        s.pop(b)
    else:
        b = (b + i) % len(s)
        s.pop(b)
r = tuple(map(int, input().split()))
for i in r:
    print(1 if i in s else 0)


Measured memory_bytes: 28564
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    auto rec = [&](auto &&rec, int b, string s) -> void {
        if (s.size()==n) {
            cout << s << endl;
            return;
        }
        rep(i,b+1) {
            string t = s;
            t += 'a'+i;
            // cout << t << " " << i << endl;
            if (i==b) rec(rec, b+1, t);
            else rec(rec, b, t);
        }
    };

    rec(rec, 1, "a");
    return 0;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		String A[] = new String[M];
		for(int i=0;i<M;i++)A[i]=sc.next();
		sc.close();
		
		String dp[] = new String[N+1]; //i本使って、できる最大の数をStringで格納
		Arrays.fill(dp, "");
		dp[0]="";
		for(int i=0;i<=N;i++) {
			for(int j=0;j<M;j++) {
				if(i-f(A[j])<0)continue;
				if(i-f(A[j])!=0&dp[i-f(A[j])]=="")continue;
				dp[i]= max(dp[i],dp[i-f(A[j])]+A[j]);
			}
		}
		System.out.println(dp[N]);		
	}	
	
	//文字Aを作るのに必要なマッチの数を返す。
	static int f(String A) {
		int a = Integer.parseInt(A);
		a--;
		int v[] = {2,5,5,4,5,6,3,7,6}; //1~9
		return v[a];
	}
	
	//文字列a,bの大きい方を返す。
	static String max(String a, String b) {
		int alen = a.length();
		int blen = b.length();
		if(alen>blen) return a;
		else if(alen<blen) return b;
		else {
			if(a.compareTo(b)>=0) return a;
			else return b;
		}
	}
}


Measured memory_bytes: 378068
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-10)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
mt19937 _mt(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l,ll r){return uniform_int_distribution<ll>(l,r-1)(_mt);}

#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;
 
int main(){
	double x1,x2,x3,y1,y2,y3;
	cin>>x1>>y1>>x2>>y2>>x3>>y3;
	double a,b,c,l,r,mx;
	a=hypot(x1-x2,y1-y2);
	b=hypot(x2-x3,y2-y3);
	c=hypot(x3-x1,y3-y1);
	l=(a+b+c)/2;
	r=sqrt(l*(l-a)*(l-b)*(l-c))/l;
	mx=max({a,b,c});
	double ok=0,ng=mx/2;
	while(ng-ok>EPS){
		double mid=(ok+ng)/2;
		bool bs=mx*(r-mid)/r>=mid*2;
		(bs?ok:ng)=mid;
	}
	fcout(10)<<ok<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

const int N = 1e5+7;

int n, m;

VPII G[N];

int ans[N];

bitset<N> vis;

void dfs(int v)
{
	vis[v] = 1;

	for(auto it:G[v])
	{
		if(!vis[it.st])
		{
			ans[it.st] = ans[v]+it.nd;
			dfs(it.st);
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	cin >> n >> m;

	while(m--)
	{
		int l, r, d;
		cin >> l >> r >> d;

		G[l].eb(r, d);
		G[r].eb(l, -d);
	}

	for(int i = 1; i <= n; ++i)
	{
		if(!vis[i])
			dfs(i);
	}

	for(int i = 1; i <= n; ++i)
	{
		for(auto it:G[i])
		{
			if(ans[it.st]!=ans[i]+it.nd)
			{
				cout << "No\n";
				return 0;
			}
		}
	}

	cout << "Yes\n";
}

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

int main(){
    string s;
    int n;
    cin >> s;
    if(s[0] == 'o') n++;
    if(s[1] == 'o') n++;
    if(s[2] == 'o') n++;
    cout << 700 + 100*n << endl;
    return 0;
}

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

int main() {
    int n, p[15], sum = 0, mx = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        sum += p[i];
        mx = max(mx, p[i]);
    }
    sum -= mx / 2;

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256