akhauriyash/Code-Regression huggingface dataset:
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

void err() { std::cout << -1 << std::endl; exit(0); }
#define require(exp) do { if (!(exp)) { err(); } } while(false)

/*
長さ n, 増加 l, 減少 m を探します。
極端なのが長方形とお山で、l+m-1 <= n <= lm です。
n を l 個のブロックに分けて、各成分が 1 以上、max が m, 合計が n になるように分けます。
全成分 1 引いておくことで、a = n - l, b = m - 1 とおくと、max が b, 合計が a です。
a = b*q + r と置くことで、b が q 個、次に r、残りは 0 です。
*/

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint n, l, m;
  std::cin >> n >> l >> m;
  debug(l,m,n);
  require(l+m <= n+1 && n <= l*m);

  auto ans = [&]  {
    std::vector<int> ans(n);
    std::iota(all(ans),0);
    if (m == 1) {
      assert(l == n);
      return ans;
    }
    lint a = n - l, b = m - 1;
    debug(a,b);
    lint q = a / b, r = a % b;
    std::vector<lint> v(l);
    rep(i,0,q) {
      v.at(i) = b;
    }
    if (0 < r) {
      assert(q < l);
      v.at(q) = r;
    }
    for (lint & x : v) x++;
    debug(v);
    std::partial_sum(all(v),v.begin());
    v.insert(v.begin(),0);

    rep(i,0,l) {
      std::reverse(ans.begin() + v.at(i), ans.begin() + v.at(i+1));
    }
    return ans;
  }();

  for (int & x : ans) x++;

  rep(i,0,n) {
    std::cout << (0 < i ? " " : "") << ans.at(i);
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 5632
//A.cpp
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main(){
  int N,Y;
  cin >> N >> Y;
  int a=-1,b=-1,c=-1;
  bool flag = true;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= N-i; j++){
      if(Y==10000*i+5000*j+1000*(N-i-j)){
        a = i, b = j, c = N-i-j;
        flag = false;
        break;
      }
    }
    if(!flag) break;
  }


  printf("%d %d %d\n",a,b,c);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
#define f(i,a,b) for(int i = a;i < b;i++)
#define ff(i,a,b)  for(int i = a-1;i>=b;i--)
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1e9+7;
//int to string -> to_string()
//string to int -> stoi()

int32_t main()
{
   IOS;
   int a,b,c;
   cin>>a>>b>>c;
   cout<<c<<" "<<a<<" "<<b<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}



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




int main() {

	ll A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	ll cost = INF;

	rep(c, (X + Y) * 3) {
		ll a = max(X - c / 2, 0);
		ll b = max(Y - c / 2, 0);
		cost = min(cost, a*A + b * B + c * C);
	}

	cout << cost;
	
		
	system("PAUSE");

}


Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int main() {
    int A, B; cin >> A >> B;
    if (A > B) {
        cout << (2 * A -1);
    } else if (B > A) {
        cout << (2 * B -1);
    } else {
        cout << (2 * A) << endl;
    }
}


Measured memory_bytes: 256
def make_tree(n):
    i = 2
    while True:
        if i >= n * 2:
            tree1 = [inf] * i
            tree2 = [0] * i
            break
        else:
            i *= 2
    return tree1, tree2

def update(i, x):
    j = len(tree1) // 2 + i
    tree1[j] = x
    j //= 2
    while True:
        if j == 0:
            break
        tree1[j] = min(tree1[2 * j], tree1[2 * j + 1])
        j //= 2
    j = len(tree2) // 2 + i
    tree2[j] = x
    j //= 2
    while True:
        if j == 0:
            break
        tree2[j] = max(tree2[2 * j], tree2[2 * j + 1])
        j //= 2
    return

def find(x, y):
    s = len(tree1) // 2 + x
    t = len(tree1) // 2 + y
    ans1 = inf
    while True:
        if s > t:
            break
        if s % 2 == 0:
            s //= 2
        else:
            ans1 = min(ans1, tree1[s])
            s = (s + 1) // 2
        if t % 2 == 1:
            t //= 2
        else:
            ans1 = min(ans1, tree1[t])
            t = (t - 1) // 2
    s = len(tree2) // 2 + x
    t = len(tree2) // 2 + y
    ans2 = 0
    while True:
        if s > t:
            break
        if s % 2 == 0:
            s //= 2
        else:
            ans2 = max(ans2, tree2[s])
            s = (s + 1) // 2
        if t % 2 == 1:
            t //= 2
        else:
            ans2 = max(ans2, tree2[t])
            t = (t - 1) // 2
    return ans1, ans2

n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = n - k + 1
s = [1] * n
for i in range(1, n):
    if p[i] > p[i - 1]:
        s[i] = s[i - 1] + 1
ans -= max(s.count(k) - 1, 0)
inf = pow(10, 7)
tree1, tree2 = make_tree(n)
for i in range(n):
    update(i, p[i])
for i in range(n - k):
    a, b = find(i, i + k)
    if a == p[i] and b == p[i + k]:
        ans -= 1
print(ans)

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

int main() {
  int a,b;
  cin >> a >> b;
  if (a%2 != 0 && b%2 != 0){
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  } 
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll p=pow(10,9)+7;
int q=998244353;
typedef long double ld;
const double PI =  3.141592653589793238;
 
ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}
 
ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
ll factorial(ll n) 
{ 
    // single line to find factorial 
    
ll ans = 1;
for (int i=1;i<=n;i++)
{
    ans = ans*i;
}
return ans;
} 
bool isPrime(int n) 
{ 
    // Corner case 
    if (n <= 1)  return false; 
  
    // Check from 2 to n-1 
    for (int i=2; i<n; i++) 
        if (n%i == 0) 
            return false; 
  
    return true; 
} 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n,m,x;
  cin>>n>>m>>x;
  ll val=n/m;
  ll rem=n%m;
  if(rem !=0)
    cout<<(val+1)*x;
  else
    cout<<val*x;
  
    
    return 0;
}







Measured memory_bytes: 3644
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
d = float('inf')
ans = 0
for i in range(n):
	d = min(d, abs(a-(t-0.006*h[i])))
	if d == abs(a-(t-0.006*h[i])):
		ans = i+1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception{
    
    Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    int x = 2 * A -1;
    int y = 2 * B -1;
    int z = A + B;
    
    System.out.println(Math.max(z,Math.max(x,y)));
  }
}

Measured memory_bytes: 21844
//It's like the first time I realized that
//All You Need Is Love


#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.2")

#include<bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()

inline void opting() {
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
}

int inp() {
    int x;
    cin >> x;
    return x;
}

void make_unique(vector<int> &vec, bool sorted = false) {
    if(!sorted)
        sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}
const int SQRT = 450, lg = 18 + 2, inlim = 2147483647;
const int maxn = 1e5 + 69, CL = 40, delta = 1e9 + 9, inf = 1e9 + 420;

bool match[maxn];
vector<int> adj[maxn];

bool win = false;
void dfs(int v, int p){

    for(auto u : adj[v])
        if(u != p)
            dfs(u, v);
    if(!match[v] and (match[p] or v == p))
        win = true;
    if(!match[v])
        match[p] = match[v] = true;
}

void add_edge(int u, int v){
    adj[u].push_back(v);
    adj[v].push_back(u);
}

int n;
void input(){
    cin >> n;
    for(int i = 1; i < n; i++)
        add_edge(inp() - 1, inp() - 1);
}

int main(){
    opting();

    input();
    dfs(0, 0);
    if(win)
        cout << "First";
    else
        cout <<"Second ";
}


Measured memory_bytes: 9340
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <queue>
#include <stack>
#define s(n) scanf("%d",&n);
#define sl(n) scanf("%lld",&n);
#define p(n) printf("%d",n);
#define pl(n) printf("%lld",n);
#define pr printf("\n");
#define LL long long
using namespace std;

const int maxn=1e5+5;
int num[maxn];

int main(){
    string s1,s2;
    cin>>s1>>s2;
    int len1=s1.length();
    int len2 = s2.length();
    if(len1<len2){
        cout<<"LESS"<<endl;
    }
    else if(len1>len2){
        cout<<"GREATER"<<endl;
    }
    else if(len1==len2){
        if(s1<s2){
            cout<<"LESS"<<endl;
        }
        else if(s1>s2){
            cout<<"GREATER"<<endl;
        }
        else{
            cout<<"EQUAL"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main(){
    int x,y;
    cin >> x >>y;
if (x<y){
    cout<<"a < b"<<endl;
    return 0;
}
if (x>y){
    cout<<"a > b"<<endl;
    return 0;
}
if (x==y){
    cout<<"a == b"<<endl;
    return 0;
}
} 


Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <cstdio>
#include <string>

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

typedef long long ll;

using namespace std;
int main()
{
    string N;
    cin >> N;
    int num = atoi(N.c_str());
    int cnt = 0;
    int i, n;
    REP(i, SIZE(N))
    {
        cnt += N[i] - '0';
    }
    if (num % cnt == 0)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 3624
import Data.List

main :: IO()
main = getContents >>= putStrLn.show.solve.formatIn

formatIn :: String -> [Int]
formatIn = reverse.sort.map read.words

solve    :: [Int] -> Int
solve [x,y] | x `mod` y == 0 = y
            | otherwise = solve [y, x `mod` y]

Measured memory_bytes: 3664
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

const long long int big = pow(10, 9) + 7;

int main(){
	int N;
	cin >> N;
	vector<int> T(N), A(N);
	for (int i = 0; i < N; i++){
		cin >> T[i];
	}
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	vector<long long int> UB(N),deci(N);
	for (int i = 0; i < N; i++){
		if (i == 0){
			UB[i] = T[i];
			deci[i] = 1;
			continue;
		}
		if (T[i]>T[i - 1]){
			UB[i] = T[i];
			deci[i] = 1;
			continue;
		}
		UB[i] = T[i];
	}
	for (int i = N-1; 0 <= i; i--){
		if (i == N-1){
			if (UB[i] < A[i]){
				cout << 0 << endl;
				return 0;
			}
			if (deci[i] == 1 && A[i] != UB[i]){
				cout << 0 << endl;
				return 0;
			}
			deci[i] = 1;
			continue;
		}
		if (A[i]>A[i + 1]){
			if (UB[i] < A[i]){
				cout << 0 << endl;
				return 0;
			}//決まる値が上限を超えている
			if (deci[i] == 1 && A[i] != UB[i]){
				cout << 0 << endl;
				return 0;
			}//決まる値が決まってる値と一致しない
			UB[i] = A[i];
			deci[i] = 1;
			continue;
		}
		if (UB[i]>A[i]){
			UB[i] = A[i];
		}
		if (deci[i] == 1 && A[i] < UB[i]){
			cout << 0 << endl;
			return 0;
		}//上限が決まってる値よりも小さくなっている
	}
	long long int sum = 1;
	for (int i = 0; i < N; i++){
		if (deci[i] == 1){
			continue;
		}
		sum = sum*UB[i]%big;
	}
	cout << sum << endl;
	/*for (int i = 0; i < N; i++){
		cout << UB[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < N; i++){
		cout << deci[i] << " ";
	}
	cout << endl;*/
	return 0;
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll l, r, d; cin >> l >> r >> d;

    ll cnt = 0;
    rep2(i, l, r+1){
        if(i%d==0) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define S second
#define F first
#define ld I64d
#include <cstdio>
#ifdef DEBUG
    #define D(X) X
#else
    #define D(X)
#endif
#define mehh ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(v) (int)v.size()
#define loop(i, v) for (int i = 0; i < sz(v); ++i)
#define PrimeRange(n) (n / log(n))
#define NumOfDigits(n) 1 + (int)log10(n)

using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int N = 2e4, M = 1e6+6, OO = 0x3f3f3f3f;
using namespace std ;

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

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

int main(){
    mehh
    int n, diff = 0, x;
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> x;
        if (x != i + 1) diff++;
    }
    (diff <= 2)? cout << "YES": cout << "NO";
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#define f(i,a,b) for(register int i=a;i<=b;++i)
using namespace std;
char a[4],b[4];
int cnt;
int main() {
    scanf("%s",a);
    scanf("%s",b);
    f(i,0,2)if(a[i]==b[i])++cnt;
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100005
#define maxm 500005
#define inf 0x7fffffff
#define ll long long
#define ld long double
#define debug(x) cerr<<#x<<": "<<x<<endl
#define fgx cerr<<"--------------"<<endl
#define dgx cerr<<"=============="<<endl

using namespace std;
struct vc{
	ld x,y;
	vc operator*(const ld b){vc t;t.x=x*b,t.y=y*b;return t;}
};
struct pt{
	ld x,y;
	pt operator+(const vc b){pt t;t.x=x+b.x,t.y=y+b.y;return t;}
	vc operator-(const pt b){vc t;t.x=x-b.x,t.y=y-b.y;return t;}
};

inline int read(){
	int x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}

inline ld cross(vc a,vc b){return a.x*b.y-a.y*b.x;}
inline pt get(){pt t;t.x=read(),t.y=read();return t;}
inline vc nl(vc a){vc b;b.x=-a.y,b.y=a.x;return b;}
inline pt glt(pt a,pt b,pt c,pt d){
	vc u=b-a,v=d-c,w=a-c;
	ld t=cross(v,w)/cross(u,v);
	return a+u*t;
}

int main(){
	pt p1=get(),p2=get();
	int Q=read();
	while(Q--){
		pt p=get(); vc a=p1-p2,b=nl(a);
		pt p0=p+b,res=glt(p1,p2,p,p0);
		printf("%.10Lf %.10Lf\n",res.x,res.y);
	}
	return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a;
    int tmp;
    int i = 0;
    int count = 0;
    int sum = 0;
    
    cin >> a;
    tmp = a;
    count++;
    for(i = 0; i < n-1; i++){
        cin >> a;
        if(tmp != a){
            sum += (count / 2);
            count = 1;
        }else{
            count++;
        }
        tmp = a;
    }
    sum += (count / 2);
    
    cout << sum << endl;
}


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

int main() {
  string n;
  cin>>n;
  rep(i,3){
    if(n[i]=='7'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3564
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif

int powe(int x, int n){
	int res = 1;
	while(n){
		if(n&1) res = (res * x) % mod ;
		x = (x * x) % mod ;
		n >>= 1; 
	}
	return res ;
}

int n ;
string s; 
int dp[N] ;

void solve()
{
	cin >> s;
	n = s.length();
	int ans = 0 , k = 0;
	// repA(i,1,n-1){
	// 	if(s[i] == '1'){
	// 		ans += powe(3, n-i-1) % mod  ;
	// 		ans %= mod ;
	// 		k++ ;
	// 	}
	// }
	int last = 1; 
	for(int i = n-1; i >= 0 ; --i){
		if(s[i] == '1'){
			last = (powe(3 , n-i-1) + 2 * (last)) % mod ; 
		}
	}
	cout << last;	
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

int main() {
    char C;
    cin >> C;
    vector<char> vec = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    for (int i = 0; i < vec.size(); i++) {
        if (C == vec[i]) cout << vec[i+1] << endl;
    } 

    return 0;
}

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

void cc(ll a,map<ll,bool>& ap,map<ll,int>& nm,vector<int>& c){
    if(!ap[a]){
        ap[a]=1;
        nm[a]=c.size();
        c.pb(a);
    }
}

struct BIT{
    vector<ll> bt;
    ll n,m;
    BIT(ll n_){
        n=n_;m=1;
        while(m<=n_) m*=2;
        m/=2;
        bt.resize(n+1);
    }
    ll sum(ll i){
        if(!i) return 0;
        return bt[i]+sum(i-(i&-i));
    }
    ll sum(ll i,ll j){
        return sum(j-1)-sum(i-1);
    }
    ll ad(ll i,ll x){
        if(i>n) return i;
        bt[i]+=x;
        ad(i+(i&-i),x);
        return i;
    }
    ll lb(ll k){
        ll x=0;
        for(int i=m;i>0;i/=2){
            if(x+i<=n&&bt[x+i]<k) {
                k-=bt[x + i];
                x+=i;
            }
        }
        return x+1;
    }
};

int main(){
    ll q;
    cin>>q;
    map<ll,bool> ap;map<ll,int> nm;vector<int> c;
    vector<ll> t(q),a(q),b(q),sb(q+1),kaa;
    fr(i,q){
        sb[i+1]=sb[i];
        cin>>t[i];
        if(!(--t[i])){
            cin>>a[i]>>b[i];
            sb[i]+=b[i];
            kaa.emplace_back(a[i]);
        }
    }
    sort(kaa.begin(),kaa.end());
    for(auto i:kaa) cc(i,ap,nm,c);
    ll m=c.size();
    BIT bt1(m),bt2(m);
    ll cnt=0,kb=0;
    fr(i,q){
        //cout<<i<<endl;
        if(t[i]){
            ll kari=kb,p=bt1.lb((cnt+1)/2);
            //cout<<bt2.sum(p+1,m+1)<<" "<<bt1.sum(p+1,m+1)<<" "<<c[p-1]<<endl;
            kari+=bt2.sum(p+1,m+1)-bt1.sum(p+1,m+1)*c[p-1];
            //cout<<bt2.sum(1,p)<<" "<<bt1.sum(1,p)<<" "<<-c[p-1]<<endl;
            kari+=-bt2.sum(1,p)+bt1.sum(1,p)*c[p-1];
            cout<<c[p-1]<<" "<<kari<<endl;
        }
        else{
            bt1.ad(nm[a[i]]+1,1);
            bt2.ad(nm[a[i]]+1,a[i]);
            cnt++;
            kb+=b[i];
        }
    }
}

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

int  main()
{
    long long int  i,no, first, second, next;
    first=2;
    second=1;

    cin>>no;
    for(i=0; i<=no; i++)
    {
        if(i == no)
        {
            cout<<first<<endl;
        }

        next = first + second;
        first = second;
        second = next;
    }
    ///cout<<first<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const ll INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
int cnt[2][105];

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	map<int, int>mp;
	rep(i, n) {
		mp[a[i]]++;
	}
	ll ans = 0;
	for (auto p : mp) {
		ll x = p.first;
		ll n = p.second;
		if (n < x)ans += n;
		else ans += n - x;
	}
	cout << ans << endl;
	return 0;
}


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



int main(){
    int n;
    cin>>n;
    int sum=0;
    int ans=0;
    for(int i=0;i<n;++i){
        int d;
        cin>>d;
        ans-=d*d;
        sum+=d;
    }
    cout<<(ans+sum*sum)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int a[100010];
	cin>>a[0];
	int m,i;
	m=a[0];
	int f=1;
	for(i=1;i<n;i++){
		cin>>a[i];
		if(a[i]<=m-2){
			f=0;
		}
		if(a[i]>m) m=a[i];
	}
	if(f==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

return 0;
}


Measured memory_bytes: 640
#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

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

    double c = C * 2 * M_PI / 360;
    double S = 1. / 2 * a * b * sin(c);
    double h = S / a * 2;
    double d = sqrt(a * a + b * b - 2 * a * b * cos(c));
    double L = a + b + d;

    for (double f : {S, L, h})
    {
        printf("%.5f\n", f);
    }
}



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

typedef long long ll;
typedef unsigned long long ull;

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

  ll ans = 0;
  if (s == "SUN") {
    ans = 7;
  } else if (s == "MON") {
    ans = 6;
  } else if (s == "TUE") {
    ans = 5;
  } else if (s == "WED") {
    ans = 4;
  } else if (s == "THU") {
    ans = 3;
  } else if (s == "FRI") {
    ans = 2;
  } else if (s == "SAT") {
    ans = 1;
  }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std ;
     
    #define pb(n) push_back(n)
    #define fi first
    #define se second
    #define all(r) begin(r),end(r)
    #define vmax(ary) *max_element(all(ary))
    #define vmin(ary) *min_element(all(ary))
    #define debug(x) cout<<#x<<": "<<x<<endl
    #define fcout(n) cout<<fixed<<setprecision((n))
    #define scout(n) cout<<setw(n)
    #define vary(type,name,size,init) vector< type> name(size,init)
    #define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
    #define mp(a,b) make_pair(a,b)
     
    #define rep(i,n) for(int i = 0; i < (int)(n);++i)
    #define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
    #define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
    #define repa(n,array) for(auto &n :(array))
     
    using ll = long long;
    using pii = pair<int,int> ;
    using pll = pair<ll,ll> ;
     
    const ll mod = 1e9+7;
    constexpr ll inf = ((1<<30)-1)*2+1 ;
    constexpr double PI = acos(-1.0) ;
    double eps = 1e-10 ;
    const int dy[] = {-1,0,1,0,1,-1,1,-1};
    const int dx[] = {0,-1,0,1,1,-1,-1,1};
     
    ll dp[51][4];
     
    int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      ll n,p;
      cin >> n >> p;
      vector<ll> v(n);
      bool f = false;
      rep(i,n){
        cin >> v[i];
        f |= v[i] % 2;
      }
      ll ans = 1;
      REP(i,0,n){
        ans *= 2;
      }
      if(f){
        if(n != 1)
          cout << ans / 2<< endl;
        else
          cout << (v[0] % 2 == p) << endl;
      }
      else{
        if(p)
          cout << 0 << endl;
        else
          std::cout << ans << std::endl;
      }
      return 0;
    }

Measured memory_bytes: 256
n, k = (int(x) for x in input().split())
A = list(int(x) for x in input().split())
F = list(int(x) for x in input().split())
A.sort()
F.sort(reverse=True)

def meguru_bisect(ng, ok):
    """
    初期値のng,okを受け取り, check=>Trueを満たす最大値(最小値)を返す
    条件を満たす最大値を求める場合、初期値は(ng:上限の外, ok:下限の外)   例) 10**9+1, -1
    条件を満たす最小値を求める場合、初期値は(ng:下限の外, ok:上限の外)   例) -1, 10**9+1
    上限の外や下限の外が返ってくる場合は条件を満たす値が範囲内になかったことを示すので、例外処理が必要
    """
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    return ok

def check(x):
    tmp = 0
    for i in range(n):
        if A[i] * F[i] > x:
            tmp += A[i] - (x // F[i])
    return tmp <= k

ans = meguru_bisect(-1, 10**12 + 1)
print(ans)


Measured memory_bytes: 111808
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

vector<int> G[100100];
int p[100001];
queue<int> q;

int main(){

    int a, b, n, m, room;
    cin >> n >> m;

    FOR(i, 0, m){
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    FORQ(i, 0, n)p[i] = 0;

    q.push(1);
    while(!q.empty()){
        room = q.front();
        q.pop();
        FOR(i, 0, G[room].size()){
            if(G[room][i] != 1 && p[G[room][i]] == 0){
                p[G[room][i]] = room;
                q.push(G[room][i]);
            }
        }
    }

    FORQ(i,2,n){
        if(p[i] == 0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    FORQ(i,2,n){
        cout << p[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 10384
import math
from heapq import heappush, heappop


def main():
    sx, sy, gx, gy = map(int, input().split())
    N = int(input())
    P = [(sx, sy, 0)] + [(gx, gy, 0)] + \
        [tuple(map(int, input().split())) for _ in range(N)]
    dist = [[0]*(N+2) for _ in range(N+2)]
    for i in range(N+2):
        for j in range(N+2):
            xi, yi, ri = P[i]
            xj, yj, rj = P[j]
            dist[i][j] = max(math.sqrt((xi-xj)**2 + (yi-yj)**2) - (ri+rj), 0.0)
    INF = float("Inf")
    ans = [INF] * (N+2)
    h = [(0.0, 0)]
    while len(h) and ans[1] == INF:
        d, i = heappop(h)
        if ans[i] != INF:
            continue
        ans[i] = d
        for j in range(N+2):
            if ans[j] == INF:
                heappush(h, (d + dist[i][j], j))
    print(ans[1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 125108
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
	
	io
	std::vector<string> res[11];
	res[1].push_back("a");    
    rep(i,2,11)
    {
        for (auto s:res[i - 1])
        {
            char c = 'a';
            for (char cc:s)
            {
                c = max(c, cc);
            }
            for (char tmp = 'a'; tmp <= min((char) (c + 1), 'z'); tmp++)
            {
                res[i].push_back(s + tmp);
            }
        }
        sort(res[i].begin(), res[i].end());
    }
    ll n;
    cin>>n;
    for(auto i:res[n])
    {
    	cout<<i<<endl;
    }
	
}

Measured memory_bytes: 11508
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(){
  long long N, ans = 0;
  cin >> N;
  vector<long long> result;
  long long boundary = sqrt(N);

  for (int i = 1; i <= boundary; i++) {
    if (N % i == 0) {
      result.push_back(i);
      if(i != (N / i) && i * i != N) result.push_back(N/i);
    }
  }
  long long rsize = result.size();
  for(int i = 0; i < rsize; i++){
    long long m = N / result[i] - 1;
    if(result[i] < m) ans += m;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  ll N; cin >> N;
  vector<vector<char> > a(N, vector<char>(N, '0'));
  vector<vector<char> > b(N, vector<char>(N, '0'));
  
  ll ans = 0;
  for(ll i = 0; i < N; i++){
    for(ll j = 0; j < N; j++){
      cin >> a[i][j];
    }
  }
  
  for(ll n = 0; n < N; n++){
    for(ll i = 0; i < N; i++){
      for(ll j = 0; j < N; j++){
        b[i][j] = a[i][(j + n)%N];
      }
    }
    bool clr = true;
    for(ll i = 0; i < N; i++){
      for(ll j = 0; j < N; j++){
        if(b[i][j] != b[j][i]) {
          clr = false;
          break;
        }
      }
    }
    if(clr) ans += N;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 512
import itertools
lis_num =[]



while True :
    count = 0
    n, x = map(int, input().split())
    if n == 0 and x == 0 :
        break
    

    lis = list(range(1, n + 1))
    

    for i in itertools.combinations(lis, 3) :
        if sum(i) == x :
            count += 1
            
    
    print(count)


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

int main(){
    ll a, b;
    cin >> a >> b;
    int k = (a+b)/2;
    if(abs(a-k) == abs(b-k)) cout << k << endl;
    else cout << "IMPOSSIBLE" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define MP make_pair
#define PB push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	printf("%.12f\n", hypot(abs(x1 - x2), abs(y1 - y2)));
}
/*
asdfghjk
   3--6
*/


Measured memory_bytes: 3264
#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 N; cin >> N;

    int k = 0;
    rep(i,N) {
        int p; cin >> p;
        if (i + 1 != p) k++;
    }

    cout << ((k == 2 || k == 0) ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) {
	if(y==0) return x;
	return gcd(y,x%y);	
}

ll lcm(ll x, ll y) {
	ll z=gcd(x,y);
	return x/z*y;
}

int main()
{
	ll n,t,ans=0;
	cin >> n >> t;
	ll a[n];
	rep(i,n) cin >> a[i];
	rep(i,n){
		if((a[i]+t)<=a[i+1]) ans+=t;
		else ans+=a[i+1]-a[i];
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

const int MAX_L = 1000001;
const int MAX_SQRT_B = 1000001;
bool is_prime_array[MAX_L];
bool is_prime_small[MAX_SQRT_B];

bool is_prime(int n) {
	for(int i = 2; i * i <= n; i++) {
		if(n % i == 0) return false;
	}
	return n != 1;
}

vector<int> divisor(int n) {
	vector<int> res;
	for(int i = 1; i * i <= n; i++) {
		if(n % i == 0) {
			res.push_back(i);
			if(i != n / i) res.push_back(n / i);
		}
	}
	return res;
}

map<int, int> prime_factor(int n) {
	map<int, int> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

int eratosthenes(int n) {
	bool is_prime[n + 1];
	memset(is_prime, true, sizeof(is_prime));
	// prime[n];

	is_prime[0] = is_prime[1] = false;
	int ans = 0;
	rep(i, 2, n + 1) {
		if(is_prime[i]) {
			// prime[ans++] = i;
			ans++;
			for(int j = 2 * i; j <= n; j += i) is_prime[j] = false;
		}
	}
	return ans;
}

// [a, b)の整数に対して篩を行う
ll segment_eratosthenes(ll a, ll b) {
	for(int i = 0; (ll)i * i < b; i++) is_prime_small[i] = true;
	for(int i = 0; i < b - a; i++) is_prime_array[i] = true;

	for(int i = 2; (ll)i * i < b; i++) {
		if(is_prime_small[i]) {
			for(int j = 2 * i; (ll)j * j < b; j += i) is_prime_small[j] = false; // [2, sqrt(b))の篩
			for(ll j = max(2LL, (a + i - 1) / i) * i; j < b; j += i) is_prime_array[j - a] = false; // [a, b)の篩
		}
	}
	ll rsl = 0;
	rep(i, 0, sqrt(b)) {
		if(is_prime_array[i]) rsl++;
	}
	return rsl;
}

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

    int N;
    cin >> N;
    vector<int> v;
    rep(i, 2, 55556) if(is_prime(i) and i % 5 == 1) v.push_back(i);

    rep(i, 0, N - 1) cout << v[i] << " ";
    cout << v[N - 1] << endl;

}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem071c(n, a))
}

fun problem071c(n: Int, a: List<Long>): Long {
    val map = mutableMapOf<Long, Int>()
    for (i in 0 until n) {
        val ai = a[i]
        if (map[ai] == null) {
            map[ai] = 1
        } else {
            map[ai] = map[ai]!! + 1
        }
    }
    val usable = map.filter { it.value >= 2 }.map { it.key to it.value }.sortedBy { it.first }
    if (usable.isEmpty()) return 0
    val x = usable[usable.size - 1]
    if (x.second >= 4) {
        return x.first * x.first
    } else {
        if (usable.size < 2) return 0
        val y = usable[usable.size - 2]
        return x.first * y.first
    }
}

Measured memory_bytes: 59044
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <string>
using namespace std;
class A
{
	string s;
	int a;
public:
	A();
};

A::A() {
	cin >> a;
	cin >> s;
	if (a < 3200) {
		cout << "red";
	}
	else {
		cout << s;
	}
}

int main(){
  A* x = new A();
  return 0;
}

Measured memory_bytes: 256
#!python3

import sys
from collections import defaultdict
from math import gcd

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = input()
    it = map(int, sys.stdin.read().split())
    mod = 10**9 + 7

    d1 = [defaultdict(int), defaultdict(int)]
    z0 = za = zb = 0
    for ai, bi in zip(it, it):
        t = ai * bi
        if t == 0:
            if ai != 0:
                za += 1
            elif bi != 0:
                zb += 1
            else:
                z0 += 1
            continue

        ci = gcd(ai, bi)
        ai, bi = ai // ci, bi // ci

        t = t < 0
        if ai < 0:
            ai, bi = -ai ,-bi

        d1[t][(ai, bi)] += 1


    a1, a2 = d1
    ans = 1
    z1 = 0
    for (ai, bi), v in a1.items():
        k2 = (bi, -ai)
        if k2 in a2:
            v2 = a2[k2]
            ans *= pow(2, v, mod) + pow(2, v2, mod) - 1
            ans %= mod
        else:
            z1 += v

    for (ai, bi), v in a2.items():
        k2 = (-bi, ai)

        if k2 in a1: continue

        z1 += v
    ans *= pow(2, za, mod) + pow(2, zb, mod) - 1
    ans %= mod
    ans *= pow(2, z1, mod)

    print((ans-1+z0) % mod)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 83048
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL LINF=1LL<<62;
const LL mod=1e9;


const int M_N=1000000;
bool prime[M_N+1];
 
void Sieve(){
    int i,j;
    prime[1]=false;
    for (i=2;i*i<=M_N;i++){
        if (prime[i]==true){
            for (j=2;i*j<=M_N;j++){
                prime[i*j]=false;
            }
        }
    }
}

int a[4001][4001];

void dfs(int i,int x,int y,int count,int sum){
    if(i%2==0) count++;
    for(int s=0;s<count;s++){
        if(i%4==0) a[y][++x]=++sum;
        if(i%4==1) a[--y][x]=++sum;
        if(i%4==2) a[y][--x]=++sum;
        if(i%4==3) a[++y][x]=++sum;
        if(sum==1000000) return;
    }
    dfs((i+1)%4,x,y,count,sum);
}

void check(int *x,int *y,int n){
    for(int i=-1000;i<=1000;i++){
        for(int j=-1000;j<=1000;j++){
            if(a[2000+i][2000+j]==n){
                *y=i+2000;
                *x=j+2000;
                return;
            }
        }
    }
}

int dp[4000][4000];

int main(){
    memset(prime,true,sizeof(prime));
    Sieve();
    int m,n;
    a[2000][2000]=1;
    dfs(0,2000,2000,0,1);
    while(cin >> m >> n){
        if(m==0&&n==0) return 0;
        memset(dp,0,sizeof(dp));
        int x,y;
        check(&x,&y,n);
        int c=1;
        dp[y][x]=prime[a[y][x]];
        int ans=dp[y][x],p=0;
        if(ans>0) p=a[y][x];
        for(int i=y;i<=y+1000;i++){
            for(int j=-c+x;j<=x+c;j++){
                if(a[i+1][j]==0||a[i+1][j]>m) continue;
                dp[i+1][j]=max({dp[i][j-1],dp[i][j],dp[i][j+1]})+prime[a[i+1][j]];
                if(ans<dp[i+1][j]){
                    ans=dp[i+1][j];
                    p=a[i+1][j];
                }
                else if(ans==dp[i+1][j]&&a[i+1][j]>p&&prime[a[i+1][j]]){
                    p=a[i+1][j];
                }
            }
            c++;
        }
        cout << ans <<" "<< p << endl;
    }
    return 0;
}


Measured memory_bytes: 74476
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <set>
using namespace std;
#define DEB(variable) cout << #variable << '=' << variable << endl

#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

using llint = long long int;

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr long long int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

void f(){
    cout<<"First"<<endl;
}
void s(){
    cout<<"Second"<<endl;
}
int main(){
    llint n,k;
    cin>>n>>k;
    vector<llint> v(n);
    REP(i,n){
        cin>>v[i];
    }
    vector<llint> dp(k+1,0);

    REP(i,k+1){
        set<llint> st;
        REP(j,n){
            if(i-v[j]>=0){
                st.insert(dp[i-v[j]]);
            }
        }
        
        REP(j,n+1){
            if(st.count(j)==0){
                dp[i]=j;
                break;
            }
        }
    }
    if(dp[k]){
       f();
    }else{
        
         s();
    }
    

    return 0;
}


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

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



Measured memory_bytes: 256
n,l=list(map(int,input().split()))
arr=[]
for i in range(1,n+1):
	arr.append(l+i-1)
sumx=sum(arr)
diff=10000000000000
ans=0
for i in range(n):
	temp=sumx-arr[i]
	if(abs(sumx-temp)<=diff):
		diff=abs(sumx-temp)
		ans=temp

print(ans)


Measured memory_bytes: 3060
N,M=map(int,input().split())
a=list(map(int,input().split()))

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

l=lcm_list(a)

for s,t in enumerate(a):
    if (l//t)%2==0:
      print("0")
      exit()

print((2*M//l+1)//2)


Measured memory_bytes: 14100