akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, c;
    cin >> n >> c;
    vector<vi> d(c, vi(c)), ci(n, vi(n));
    rep(i, c) rep(j, c) cin >> d[i][j];
    rep(i, n) rep(j, n) {
        cin >> ci[i][j];
        ci[i][j]--;
    }
    vector<vi> sum(3, vi(c));
    rep(i, n) rep(j, n) {
        rep(k, c) sum[((i+1)+(j+1))%3][k] += d[ci[i][j]][k];
    }
    int ans = INF;
    rep(i, c) rep(j, c) rep(k, c) {
        if (!(i!=j&&j!=k&&k!=i)) continue;
        int val = sum[0][i] + sum[1][j] + sum[2][k];
        ans = min(ans, val);
    }
    cout << ans << endl;
    return 0;
}


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

#define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define ll unsigned long long

int main(){
	fast
	
	int n;
	cin>>n;
	
	vector<int>diffs;
	int d1,d2;
	for(int i = 0; i < n; i++)
	{
		cin>>d1;
		cin>>d2;
		
		int ch = (d1==d2);
		
		diffs.emplace_back(ch);
	}
	
	int cnt=1;
	int max =0;
	for(int i =0; i < n-1; i++){
		if(diffs[i]==diffs[i+1] && diffs[i] == 1){
		 cnt++;
		}
		else 
		{
			if(max<cnt)
			{
				max=cnt;
			}
			cnt=1;
		}
	}
	if(max<cnt)
	{
		max=cnt;
	}
	
	if(max >= 3)
	{
		cout << "Yes"<<endl;
	}
	
	else cout << "No"<<endl;
	
	return 0;
}


Measured memory_bytes: 3600
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a, b = MAP()

# 全部正の範囲内
if a > 0:
    print('Positive')
# 全部負の範囲内
elif b < 0:
    # 何個かけるかの偶奇で正負は決まる
    if (abs(b-a)+1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')
# 0をまたげば必ず0
else:
    print('Zero')


Measured memory_bytes: 5156
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<vector<ll>> vec(c+1,vector<ll>(d+1,0));
  vec[a][b] = 1;
  rep(i,c){
    rep(j,d){
      vec[i+1][j+1] += vec[i][j+1] * (j+1);
      vec[i+1][j+1] %= mod;
      vec[i+1][j+1] += vec[i+1][j] * (i+1);
      vec[i+1][j+1] %= mod;
      vec[i+1][j+1] -= vec[i][j] * i % mod * j % mod;
      vec[i+1][j+1] = (vec[i+1][j+1]+mod) % mod;
    }
  }
//  rep(i,c+1){
//    rep(j,d+1){
//      cout << vec[i][j] << " ";
//    }
//    cout << endl;
//  }
  cout << vec[c][d] << endl;
}


Measured memory_bytes: 73616
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) { lhs = rhs; return true; }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) { lhs = rhs; return true; }
  return false;
}

struct range {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int64_t l_, int64_t r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

struct revrange {
  struct itr {
    int64_t i;
    constexpr itr(int64_t i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int64_t operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int64_t l_, int64_t r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

constexpr i32 inf32 = (i32(1) << 30) - 1;
constexpr i64 inf64 = (i64(1) << 62) - 1;

int main() {
  u32 a, b;
  std::cin >> a >> b;
  std::cout << a * b << '\n';
  return 0;
}


Measured memory_bytes: 3616
#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() {
    int x;
    cin >> x;
    if(x>=30){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}



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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  int b = 0;
  int cnt = 0;
  rep(i, n){
    if(s[i] == ')'){
      if(cnt == 0){
        b++;
      }else{
        cnt--;
      }
    }else{
      cnt++;
    }
  }

  string ans;
  rep(i, b) ans += "(";
  ans += s;
  rep(i, cnt) ans += ")";
   
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(h, n) for (int h = 0; h < (n); ++h)
#define repp(h, a, b) for (int h = a; h <= (b); ++h)
#define repr(h, a, b) for (int h = a; h >= (b); --h)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  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;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降は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;
  }
};

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  K--;

  if (W == 1) {
    cout << 1 << endl;
    return 0;
  }

  mint dp[H + 1][W];
  // fill((mint*)dp, (mint*)(dp + W), 0);
  rep(i, H + 1) {
    rep(j, W) {
      dp[i][j] = 0;
    }
  }

  int H_1[] = {1, 2, 3, 5, 8, 13, 21, 34};

  dp[0][0] = 1;
  repp(h, 1, H) {
    rep(k, W) {
      if (k == 0) {
        int c = H_1[W - 2];
        int r = H_1[max(0, W - 3)];
        dp[h][0] = dp[h - 1][0] * c + dp[h - 1][1] * r;
      } else if (k == W - 1) {
        int c = H_1[W - 2];
        int l = H_1[max(0, W - 3)];
        dp[h][W - 1] = dp[h - 1][W - 1] * c + dp[h - 1][W - 2] * l;
      } else {
        int c = H_1[k - 1] * H_1[W - k - 2];
        int l = H_1[max(0, k - 2)] * H_1[W - k - 2];
        int r = H_1[k - 1] * H_1[max(0, W - k - 3)];
        dp[h][k] =
            dp[h - 1][k] * c + dp[h - 1][k - 1] * l + dp[h - 1][k + 1] * r;
      }
    }
  }
  cout << dp[H][K].x << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
using namespace std;
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(int)(n); i++)
typedef long long ll;
const int INF = numeric_limits<int>::max();
const int MOD = (1e9 + 7);

int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  bool can = 0;
  if(x == (W/2) && y == (H/2)){
    can = 1;
  }
  cout << (double)(W*H)/2 << " " << can << endl;
  
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	final long n = stdin.nextLong();
	System.out.println( solve( n ) );
	
    }

    static long solve( long n ) {
	if ( n <= 1 ) {
	    return 1L;
	} else {
	    return n * solve( n - 1L );
	}
    }    
}

Measured memory_bytes: 17148
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef uint64_t ull;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    ull sumall = 0;
    vector<ull> a(n, 0);

    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    
    sumall += a[n-1];
    int c = 2;
    for(int i=n-2; i>0; i--){
        if(c<n){
            sumall += a[i];
            c++;
        }
        if(c<n){
            sumall += a[i];
            c++;
        }
    }
    cout << sumall << endl;

    
    return 0;
}


Measured memory_bytes: 4780
/*
Name                     : Harry Singh (:)
Age                      : 20 (:)
College                  : Lovely Professional University (:)
Email                    : harryamneet600@gmail.com (:)
Hobbies                  : Coding and Typeracer (:)
Goal                     : Long term is fixed and Short term is changing everyday (:)
Relatoinship Status      : Single (:)
Phone no                 : 91-********77 (:)
Waheguru Ji ka Khalsa, Waheguru Ji ki Fateh;
*/
#include<bits/stdc++.h>
#define int long long
#define double double
#define io ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define ipair pair<int,int>
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,n) for(int i=n;i>=0;i--)
#define F(i,n) for(int i=1;i<=n;i++)
#define f_a(a,i,n) for(int i=a;i<=n;i++)
#define f_b(a,i,b) for(int i=a;i<=b;i++)
#define FO(i,n) for(int i=n;i>=1;i--)
#define mod 1000000007
using namespace std;
#define tr cout<<"\n" 
#define br break
#define N 300005 
#define inf 10000000000000009
 
void Waheguru()
{
 
int n,k;
cin>>n>>k;
int p[n+1],c[n+1];
f(i,n)cin>>p[i],--p[i];
f(i,n)cin>>c[i];

vector<int> dp[n+1];
f(i,n)
{
	int sum=0;
	int start=i;
	while(true)
	{
		start=p[start];
		sum+=c[start];
		dp[i].pb(sum);// consecutive sums baby
		if(i==start)break;
	}
}
int ans=-inf;
f(i,n)
{
	int len=dp[i].size();
	for(int j=0;j<min(k,len);j++)
	{
      int sum=dp[i][j];//    Consecutive sums pencoh
      int with_out=k-(j+1);
      int left=with_out/dp[i].size();
      ans=max(ans,sum);
      sum+=left*dp[i].back();
      ans=max(sum,ans);
	}
}

cout<<ans;tr;
	
}
 
 
 
 
int32_t main()
{
#ifndef ONLINE_JUDGE
 freopen("input.txt","r",stdin);
 freopen("output.txt","w",stdout);
#endif
    io;
    int g=1;
    while (g--)Waheguru();
    return 0;
}

Measured memory_bytes: 218852
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll N; cin>>N;
    ll sum = 0;
    ll ans = 0;
    for(ll i=0;i<N;++i)
    {
        ll val; cin>>val;
        if(i == 0)
        {
            sum = val;
            continue;
        }
        
        ans = (ans + val*sum) % MOD;
        sum = (sum + val) % MOD;
        
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#! usr/bin/env python
# -*- coding: utf-8 -*-


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))

    a.append(x)
    a.sort()

    g = a[1] - a[0]
    for i in range(n):
        g = gcd(g, a[i+1]-a[i])

    print(g)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(int i=s;i<n;i++)
	
int main(){
	string S;
	cin >> S;
	if(S[0]==S[1]||S[1]==S[2]||S[2]==S[3]) cout << "Bad";
	else cout << "Good";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 0) {
            if (a[i] % 3 != 0 && a[i] % 5 != 0) {
                cout << "DENIED";
                return 0;
            }
        }
    }
    cout << "APPROVED";
    return 0;
}

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){
}
int main(){
    //input
    int n, m, X, Y;
    vector<int> x,y;
    cin >> n >> m >> X >> Y;

    int t;
    for (int i = 0; i < n; i++){
        cin >> t;
        x.push_back(t);
    }
    for (int i = 0; i < m; i++){
        cin >> t;
        y.push_back(t);
    }

    bool ans = false;
    if (X < Y){
        int xmax = *max_element(all(x));
        int ymin = *min_element(all(y));
        int z_range = X+1; //to Y
        vector<int> v;
        for (int i = z_range; i <= Y; i++){
            v.push_back(i);
        }
        sort(all(v));

        int z_range2 = xmax + 1; // to ymin
        if (xmax < ymin){
            for (int i = z_range2; i <= ymin; i++){
                if (binary_search(all(v),i)){
                    ans = true;
                    break;
                }
            }
        }
    }
    //判定
    if (ans == true){
        cout << "No War" << endl;
    } else {
        cout << "War" << endl;
    }

    //output
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n, l;
    cin>>n>>l;
    vector<string> v(n);
    
    for(int i=0; i<n; i++){
        cin>>v[i];
    }
    
    sort(v.begin(), v.end());
    
    string str;
    for(int i=0; i<n; i++){
        str+=v[i];
    }
    
    cout<<str<<endl;
}


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

int main() {
    int n;
    cin>>n;
    double sum=0;
    vector<pair<double, string>> oto(n);
    for(int i=0;i<n;i++) cin>>oto.at(i).first>>oto.at(i).second;
    for(int i=0;i<n;i++) {
        if(oto.at(i).second=="JPY") sum+=oto.at(i).first;
        else if(oto.at(i).second=="BTC") {
          double a;
          a=380000.0*(float)oto.at(i).first;
          sum+=a;
        }
    }
    printf("%.8lf\n", sum);
} 

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



int main()
{
	int D,n;
	cin >> D;
	n = 25 - D;
	cout<<"Christmas"<<endl;
	for (int i = 0; i < n; i++){
		cout << "Eve" << endl;

	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
   
const int N = 202;
int g[N][N];
int G(int w, int b){
    if(g[w][b]>=0) return g[w][b];
   
    bool a[N]={};
    if(w>0) a[G(w-1,b)] = true;
    for(int i=1; i<=min(w,b); ++i) a[G(w,b-i)] = true;
    if(b>0) a[G(w+1,b-1)] = true;
   
    int ret = 0;
    while(a[ret]) ++ret;
    return g[w][b] = ret;
}
   
int main(){
    memset(g,-1,sizeof(g));
    int n;
    cin >>n;
    int a = 0;
    while(n--){
        int w,b;
        cin >>w >>b;
        a ^= G(w,b);
    }
    cout << !a << endl;
    return 0;
}


Measured memory_bytes: 3320
// Problem : Rabbo Loves Jumping
// Contest : CodeChef - ketek[i] QuickMatch 25
// URL : https://www.codechef.com/KQKM2020/problems/HRJMP
// Memory Limit : 256 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

/*/ Author:Amar1503/*/
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
#define fio ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ull unsigned long long
#define ll long long
#define inf 1e9
#define mninf INT_MIN
#define Mod 1000000007
#define endl "\n"
#define cp(x) cout<<(x)<<" "
#define cl(x) cout<<(x)<<endl
#define ct(x,y) cout<<(x)<<" "<<(y)<<endl;
#define nl   cout<<endl
//const double PI=3.1415926535897932384626433832;
//looping
#define For(i,a,b) for(int i=a;i<b;i++)
#define test(t)  int (t); cin>>(t); while((t)--)
#define array(a,n) int (n); cin>>(n); int a[n]; for(int i=0;i<(n);i++) cin>>a[i];
#define trace(x) clog<<#x<<": "<<x<<" "<<endl
#define trace2(x,y) clog<<#x<<": "<<x<<"     "<<#y<<" "<<y<<endl
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define printv(v)  for(int i=0;i<(v).size();i++) cout<<v[i]<<" "
//containers
#define F first
#define S second
#define pb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define itr(it, a) for(auto it = (a).begin(); it != (a).end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ers(v)   sort(all(v)); (v).erase(unique(all(v)),(v).end())
#define printmatrix(a,n,m) for(int i=0;i<n;i++){ for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
typedef pair <int, int> pii;
typedef vector < pair <int, int> > vpii;
// cout<<"\nTime Elapsed : " << 1.0*clock() /CLOCKS_PER_SEC << " s\n";
int dx[8]={1,-1,0,0,1,1,-1,-1};
int dy[8]={0,0,1,-1,1,-1,1,-1};
#define int long long
/*/----------------------------Code begins----------------------------------/*/
int32_t main(){
fio;
int n,W;
cin>>n>>W;
vector<int> dp(W+1);//0....W  by default initialized to 0
//dp[i] is the maximum value with weight exactly equal to wi
for(int i=0;i<n;i++){
	int wt,val;
	cin>>wt>>val;
	for(int wt_already=W-wt;wt_already>=0;wt_already--){
		dp[wt_already+wt]=max(dp[wt_already+wt],dp[wt_already]+val);
	}
}
cout<<*max_element(dp.begin(),dp.end());
}








Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N=1e6;
const LL INF=1e16;
int n;
LL now[N+10],sum[N+10],f[N+10];
struct data {
    LL x,y;
}a[N+10];
bool cmp1(data p,data q) {
    return p.x<q.x;
}
bool cmp2(data p,data q) {
    return p.y<q.y;
}
int main() {
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        scanf("%lld%lld",&a[i].x,&a[i].y);
    sort(a+1,a+n+1,cmp2);
    for (int i=1;i<=n;i++) {
        sum[i]=sum[i-1]+a[i].y;
        now[i]=sum[i]-a[i].y+a[i+1].y;
    }
    sort(a+1,a+n+1,cmp1);
    for (int i=n;i>=1;i--) f[i]=f[i+1]+a[i].y;
    LL nowx=0,ans=f[1];
    for (int i=1;i<=n;i++) {
        nowx+=a[i].x;
        if (i==n) {
            ans=min(ans,nowx);
            continue;
        }
        if (f[i+1]!=sum[n-i]) {
            ans=min(ans,nowx+sum[n-i]);
            continue;
        }
        ans=min(ans,min(nowx+sum[n-i]-a[i].x+a[i+1].x,nowx+now[n-i]));
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9984
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n) for(unsigned int i=0;i<n;++i)
#define RREP(i,n) for(unsigned int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define INF 1000000001
#define MOD 1000000007

using namespace std;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q, cnt = 0;
	cin >> n;
	vector<int> s(n);
	REP(i, n) {
		cin >> s[i];
	}
	cin >> q;
	vector<int> t(n);
	REP(i, q) {
		cin >> t[i];
	}
	REP(i, q) {
		int a = t[i];
		REP(j, n) {
			if (s[j] == a) {
				cnt++;
				break;
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int main(){
  set<int> distinct;
  int n;
  cin >> n;
  int arr[200001];
  for(int i = 0; i < n; i++){ 
    cin >> arr[i];
    distinct.insert(arr[i]);
  }
  if(distinct.size() < n) cout << "NO" << endl;
  else cout << "YES" << endl;
}

Measured memory_bytes: 10368
#include<iostream>

bool isPrime(int a){
	bool ans = true;
	for(int i = 3; i*i <= a; i+=2){
		if(a%i == 0 || (a-2)%i == 0 || (a-6)%i == 0 || (a-8)%i == 0){
			ans = false;
			break;
		}
	}
	return ans;
}

int n;

int main(){
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		if(n%2 == 0)
			n--;
		for(; n>12; n-=2){
			if(isPrime(n)){
				std::cout << n << std::endl;
				break;
			}
		}
	}
}

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

int main()
{
    string x;
    cin >> x;
    int hi = atoi(x.substr(0, 2).c_str());
    int lo = atoi(x.substr(2).c_str());
    bool chi = hi > 0 && hi < 13;
    bool clo = lo > 0 && lo < 13;
    // cout << hi << endl;
    // cout << lo << endl;
    if (chi && clo)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (chi && !clo)
    {
        cout << "MMYY" << endl;
    }
    else if (!chi && clo)
    {
        cout << "YYMM" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }
    return 0;
}


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

vector<int> v;

bool f(int n, int x) {
    if (n == v.size()) {
        return (x == 0 ? true : false);
    } else {
        return f(n + 1, x) || f(n + 1, x - v[n]);
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, q, x;
    cin >> n;
    for (int i = 0; i < n; i++) { cin >> x; v.pb(x); }
    cin >> q;
    while(q--) {
        int a;
        cin >> a;
        cout << (f(0, a) ? "yes" : "no") << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, ans = 1e13;

int main() {
	cin >> N;
	for (int i = 1; (ll)i * i <= N; i++) {
		if (N % i == 0)ans = min(ans, i + N / i - 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define mp make_pair
#define print(con) for(auto it=con.begin() ; it!=con.end(); it++) \
						cout << *it <<" ";
using namespace std;

int main(){
	
	int arr[3];
	for(int i=0;i<3;i++)
	cin >> arr[i];
	int  req = 10000000;

	int a[6];
	a[0] = arr[0] + arr[1];
	a[1] = arr[2] + arr[1];
	a[2] = arr[1] + arr[2]; 
	a[3] = arr[0] + arr[2];
	a[4] = arr[2] + arr[0];
	a[5] = arr[1] + arr[0];
	for(int i=0;i<6;i++)
		req = min(req , a[i]);
	cout << req;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

const int maxn = 9001;
long long dp[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, t;
	cin >> n >> t;
	
	pi p[n];
	for(int i = 0; i < n; i++){
		cin >> p[i].first >> p[i].second;
	}
	
	sort(p, p + n);
	
	long long ret = 0;
	for(pi i : p){
		for(int j = t - 1; j >= 0; j--){
			dp[j + i.first] = max(dp[j + i.first], dp[j] + i.second);
			ret = max(ret, dp[j + i.first]);
		}
	}
	
	cout << ret << endl;

	return 0;
} 

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int Y = Integer.parseInt(sc.next());

        // 場合の数にNも入る(i<=N)
        // i = 0 の時、全ての j(5000円)のパターン(j=0,...,(N - 0)) とそれに連動して決まる k(1000円)のパターンについて試行する
        // これを i=0,...,N まで、全パターン繰り返して全てのパターンにおける合計金額を産出し、Yに等しいものは所定のフォーマットで出力する
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= (N - i); j++) {
                int k = N - i - j;
                int y = i * 10000 + j * 5000 + k * 1000;
                if (Y == y) {
                    System.out.println(i + " " + j + " " + k);
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 87;
void solve(int n, int c, const string & s, vector<int> & dp)
{
    dp.assign(n, 0);
    int pr = 0;
    deque<pair<int, int>> dk;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'o') {
            while (dk.size() && dk[0].first + c < i) {
                pr = dk[0].second;
                dk.pop_front();
            }
            dp[i] = pr + 1;
            dk.emplace_back(i, dp[i]);
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k, c;
    cin >> n >> k >> c;
    string s;
    cin >> s;
    vector<int> dp1, dp2;
    solve(n, c, s, dp1);
    reverse(begin(s), end(s));
    solve(n, c, s, dp2);
    reverse(begin(s), end(s));
    reverse(begin(dp2), end(dp2));
    vector<int> idx, wp;
    for (int i = 0; i < n; ++i)
        if (s[i] == 'o') {
            idx.push_back(i);
            wp.push_back(dp1[i]);
        }
    for (int j = 0; j < idx.size(); ++j) {
        if (dp1[idx[j]] + dp2[idx[j]] - 1 != k)
            continue;
        int w = 0;
        int x = INT_MIN;
        if (j) {
            w = dp1[idx[j - 1]];
            x = lower_bound(begin(wp), end(wp), w) - begin(wp);
            x = idx[x];
        }
        int r = upper_bound(begin(idx), end(idx), x + c) - begin(idx);
        if (r == j)
            ++r;
        if (r < idx.size())
            w += dp2[idx[r]];
        if (w < k) {
            cout << idx[j] + 1 << '\n';
        }
    }
}


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

int main(void)
{
	int d[5];

	for(int i = 0; i < 5; i++)
		cin >> d[i];
	sort(d,d+5);
	cout << d[4];
	for(int i = 3; i >= 0; i--)
		cout << ' ' << d[i];
	cout << endl;


	return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

int a,b;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>a>>b;
    ll ans = -1;
    rep(i,1000000){
        if((int)(i*0.08) == a && (int)(i*0.1) ==b){
            ans = i;
            break;
        }
    }
    print(ans);
    return 0;
}

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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

char c[limit];
int n;

signed main(){
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  
  cin>>c;
  n = strlen(c);
  
  for(int i=0;i<n;i+=2)cout<<c[i];
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 384
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            int[] arr = cin.ReadIntArray(2);
            Console.WriteLine(arr[0] / arr[1] + (arr[0] % arr[1] == 0 ? 0 : 1));
           // Console.ReadLine();
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int, int>> poss(h * w);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int a; cin >> a;
            a--;
            poss[a] = {i, j};
        }
    }
    vector<vector<ll>> lens(h * w, vector<ll>(20));
    for(int i = 0; i < h * w; i++){
        if(i + d >= h * w){ continue; }
        lens[i][0] = abs(poss[i].first - poss[i + d].first) + abs(poss[i].second - poss[i + d].second);
    }
        for(int j = 1; j < 20; j++){
    for(int i = 0; i < h * w; i++){
            if(i + d * (1ll << j) >= h * w){ continue; }
            ll i2 = i + d * (1 << (j - 1));
            lens[i][j] = lens[i][j - 1] + lens[i2][j - 1];
            if(i == 0){printd(i, j, i2, lens[i][j - 1], lens[i2][j - 1]);}
        }
    }
    prints(lens);
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        l--; r--;
        ll ans = 0;
        while(l != r){
            int len = (r - l) / d;
            int lsb;
            for(lsb = 0; (len & (1 << lsb)) == 0; lsb++){ }
            ans += lens[l][lsb];
            l += d * (1 << lsb);
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 19456
import java.awt.*;
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        int k=sc.nextInt();
        int a=sc.nextInt(),b=sc.nextInt();
        int r=(b/k)-((a-1)/k);
        if (r>=1){
            System.out.println("OK");
        }else System.out.println("NG");
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 25396
import sys
def color(x):
  if x<400:return('灰')
  elif 399<x<800:return('茶')
  elif 799<x<1200:return('緑')
  elif 1199<x<1600:return('水')
  elif 1599<x<2000:return('青')
  elif 1999<x<2400:return('黄')
  elif 2399<x<2800:return('橙')
  elif 2799<x<3200:return('赤')
  else:return('*')
input()
l=list(map(int,input().split()))
l=[color(i) for i in l]
v=l.count('*')
c=v==len(l)
l=len(set(l))
if v==0:
  print(' '.join([str(l)]*2))
  sys.exit()
else:
  if c:v-=1
  else:l-=1
  print(l,end=' ')
print(l+v)

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * Main
 */
public class Main {
  public static void main(String[] args) {
    (new Main()).run();
  }

  public void run() {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int size = 0;
    for (int i = 0; i < m; i++) {
      int task = sc.nextInt();
      size += task;
    }
    int result = n - size;
    System.out.println(result < 0 ? -1 : result);
  }
}

Measured memory_bytes: 46432
// AOJ 2883: Proof of Knowledge
// 2018.7.11 bal4u

#include <stdio.h>

char tr['d'+1];

char *calc(int *ans, char *S, char *P)
{
	int v1, v2;
	char op;
	
    if (*S == '[') {
        op = *(++S), S++;
        if (*S == '[') S = calc(&v1, S, P);
        else v1 = P[tr[*S++]];

        if (*S == '[') S = calc(&v2, S, P);
        else v2 = P[tr[*S++]];
		
        if      (op == '+') *ans = v1 | v2;
        else if (op == '*') *ans = v1 & v2;
        else                *ans = v1 ^ v2;
	} else *ans = P[tr[*S++]];
    while (*S == ']') S++;
    return S;
}

char S[100];
int main()
{
	int i, k, val, cnt;
	char P[10];
	
	for (i = 0; i < 4; i++) tr['a'+i] = i;
	while (fgets(S, 100, stdin) && *S != '.') {
		fgets(P, 10, stdin);
		for (i = 0; i < 4; i++) P[i] &= 0xf;
		calc(&val, S, P), cnt = 0;
		for (P[0] = 0; P[0] <= 9; P[0]++)
			for (P[1] = 0; P[1] <= 9; P[1]++)
				for (P[2] = 0; P[2] <= 9; P[2]++)
					for (P[3] = 0; P[3] <= 9; P[3]++) {
						calc(&k, S, P);
						if (k == val) cnt++;
					}
		printf("%d %d\n", val, cnt);
	}
	return 0;
}



Measured memory_bytes: 2040
N=int(input())
MOD=10**9+7
L=60
ls=[int(s) for s in input().split()]
bi_ls=[0 for _ in range(L)]
for i in range(N):
  for j in range(L):
    if (2**j)&ls[i]>0:
      bi_ls[j]+=1    
ans=0
base=1
for j in range(L):
  ans=(ans+bi_ls[j]*(N-bi_ls[j])*base)%MOD
  base*=2%MOD
print(ans)

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

using namespace std;

#define endl '\n'

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

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 998244353;

const int xyz = 'R' + 'G' + 'B';

int oneside(string &s) {
    int t0 = 0, c0 = 0;
    int t1 = 0, c1 = 0;

    int ans = 1;

    for (auto x : s) {
        if (x == c1) {
            if (--t1 == 0) c1 = 0;
        } else if (t0) {
            if (x == c0) {
                t0++;
            } else {
                ans = 1LL * ans * t0-- % mod;
                t1++;
                c1 = xyz - x - c0;
            }
        } else {
            t0++;
            c0 = x;
        }
    }

    return ans;
}

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

    int n; cin >> n;

    string s; cin >> s;

    int64 answer = 1;

    for (int i = 2; i <= n; ++i){
        answer = 1LL * answer * i % mod;
    }

    answer = 1LL * answer * oneside(s) % mod;

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

    answer = 1LL * answer * oneside(s) % mod;

    cout << answer << endl;

    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N, K,D;
ll mk[1111];

ll i, j, k,ans;
int main(){
    scanf("%lld%lld", &N, &K);
    ans = N;
    fornum(i,0,K){
        scanf("%lld", &D);
        fornum(j,0,D){
            ll a;
            scanf("%lld", &a);
            if(mk[a]==0){
                ans--;
                mk[a]++;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3820
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long int64;

const int MAX_M = 20;
int ms[MAX_M];
int N, M;

bool init(){
	scanf("%d%d", &N, &M);
	for(int i=0; i<M; i++){
		scanf("%d", ms + i);
	}

	return N>0 || M>0;
}

int64 lcm(int64 x, int64 y){
	return x / __gcd(x, y) * y;
}

double solve(){
	double ret = 0;
	int cnt = 0;

	for(int bit=0; bit<(1<<M); bit++){
		int64 l = 1;
		for(int i=0; i<M; i++)if((bit>>i)&1){
			l = lcm(l, ms[i]);
		}
		int64 sign = __builtin_parity(bit) ? -1 : 1;
		cnt += sign * (N / l);
		ret += sign * l * (1 + N / l) * (N / l) / 2;
	}

	return cnt ? ret / cnt : 0;
}

int main(){
	while(init()){
		printf("%.8f\n", solve());
	}

	return 0;
}

Measured memory_bytes: 796
n,k = map(int,input().split())
a=list(map(int,input().split()))
def gcd(x,y):
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
g=a[0]
for i in range(1,n):
    g=gcd(g,a[i])
if k>max(a):
    print("IMPOSSIBLE")
else:
    if k%g==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

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

using namespace std;

int main() {

    int64_t n, d;
    cin >> n >> d;

    vector<int64_t> x(n), y(n);
    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int64_t dist2 = x[i] * x[i] + y[i] * y[i];
        if (dist2 <= (d * d))
            ans++;
    }

    cout << ans << endl;

    return 0;
}

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


int main(){
  string N;
  cin>>N;
  long long int total=0 ;
  int num = 0;
  for(int i=0;i<N.size();i++){
    long long int dig = 1;
    for(int j=0;j<i;j++){dig*=10;}
    total+=(N.at(N.size()-i-1)-'0')*dig;
    num+=N.at(N.size()-i-1)-'0';
  }
  string ans ="No";
  if(total%num==0)ans ="Yes";

  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;
 public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int cost1  = Math.abs(b - a);
        int cost2  = Math.abs(c - a);
        int cost3  = Math.abs(c - b);
        so.println(Math.min(cost3 + cost1, Math.min(cost1 + cost2, cost2 + cost3)));
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  string s; cin >> s;
  rep(i, s.size()) {
    if(i%2) {
      if(s[i] == 'R') {
        cout <<"No"<<endl;
        return 0;
      }
    } else {
      if(s[i] == 'L') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] x = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int mod = 1000000007;
		long[] p = new long[n];
		long[] pi = new long[n];
		p[0] = 1;
		pi[0] = 1;
		long[] d = new long[n];
		for (int i = 1; i < n; i++) {
			p[i] = p[i - 1] * i % mod;
			pi[i] = modinv(p[i], mod);
			d[i] = x[i] - x[i - 1];
		}

		long[] b = new long[n];
		b[1] = 1;
		for (int i = 2; i < n; i++) {
			b[i] = (b[i - 1] * i + p[i - 1]) % mod;
		}
		long[] c = new long[n];
		for (int i = 1; i < n; i++) {
			c[i] = b[i] * p[n - 1] % mod * pi[i] % mod;
		}

		long ans = 0;
		for (int i = 1; i < n; i++) {
			long val = c[i] * d[i];
			ans += val;
			ans %= mod;
		}
		System.out.println(ans);
	}

	static long modinv(long a, long m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr long double PI = 3.1415926535897932384626433832795028L;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int N, X;
int L[110000], Lcc[110000];
signed main() {
    cin >> N >> X;
    rep(i, N) { cin >> L[i]; }
    rep(i, N) { Lcc[i + 1] = Lcc[i] + L[i]; }
    int ans = 0;
    rep(i, N + 1) { if (Lcc[i] <= X) { ans++; }}
    cout << ans << endl;
}

Measured memory_bytes: 256