akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int mu[100010], prim[100010], vis[100010];
int cnt;
void get_mu(int x)
{
    mu[1]=1;
    for(int i=2;i<=x;i++)
    {
        if(!vis[i]){prim[++cnt]=i;mu[i]=-1;}
        for(int j=1;j<=cnt&&prim[j]*i<=x;j++)
        {
            vis[prim[j]*i]=1;
            if(i%prim[j]==0)break;
            else mu[i*prim[j]]=-mu[i];
        }
    }
 }


int n, k;
const ll mod = 1000000007;
ll powe(ll x, ll y)
{
    if(!y) return 1;
    ll ret = powe(x, y>>1);
    ret = ret * ret % mod;
    if(y&1) ret = ret * x % mod;
    return ret;
}
ll F(int g)
{
    return powe(k / g, n);
}
ll f(int g)
{
    ll ret = 0;
    for(int i=1; i<=k/g; i++)
    {
        ll add = F(i*g) * mu[i];
        ret = (ret + add) % mod;
    }
    return ret;
}

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    get_mu(100000);
    cin >> n >> k;
    ll ans = 0;
    for(int g = 1; g<=k; g++)
    {
        //cout << g << " " << F(g) << " " << f(g) << endl;
        ans = (ans + f(g) * g) % mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4488
i,o,t,j,l,s,z=map(int,input().split())
ans=0

#oは加えるしか使い道がないので加算。
ans+=o

#j,lは２つずつ使って２を作るかi,j,lを１つずつ使って３を作るか
#最適戦略は3種の偶奇について、２種類以上が偶数個になるまで３を作ること(最大試行1回）。
#その後、各種２N個ずつ消費していけば、無駄になる個数を最小化できる。

if i>0 and j>0 and l>0:
  evn=0
  if j%2==0:
    evn+=1
  if l%2==0:
    evn+=1
  if i%2==0:
    evn+=1
#奇数個の種類が多いのならば１度だけ３を作る。
  if evn<2:
    ans+=3
    i-=1
    j-=1
    l-=1
    
#あとは全て２つずつ組み合わせていくのが最適。
ans+=(i//2)*2
ans+=(j//2)*2
ans+=(l//2)*2

#その他のピースでは長方形は作れない。
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>

using namespace std;

#define N 26
#define NIL -1

//array
int parent[N];
int leftc[N];
int rightc[N];
int root;
void Preorder(int now){
  if(now!=NIL){
    printf(" %d",now);
    Preorder(leftc[now]);
    Preorder(rightc[now]);
  }
}

void Inorder(int now){
  if(now!=NIL){
    Inorder(leftc[now]);
    printf(" %d",now);
    Inorder(rightc[now]);
  }
}

void Postorder(int now){
  if(now!=NIL){
    Postorder(leftc[now]);
    Postorder(rightc[now]);
    printf(" %d",now);
  }
}

int main(){
  int i,j,n;
  int id,child1,child2;

  //load data
  scanf("%d",&n);
  
  //initialize
  for(i=0;i<N;i++){
    parent[i]=NIL;
    leftc[i]=NIL;
    rightc[i]=NIL;
  }

  for(i=0;i<n;i++){
    
    //load data
    scanf(" %d %d %d",&id,&child1,&child2);

    //set parent
    parent[child1]=id;
    parent[child2]=id;
    
    //set left right
    leftc[id]=child1;
    rightc[id]=child2;
    
  }
  for(i=0;i<n;i++){
    if(parent[i]==NIL){
      root=i;
      break;
    }
  }
  //cout <<root<<endl;
  printf("Preorder\n");
  Preorder(root);
  printf("\n");
  printf("Inorder\n");
  Inorder(root);
  printf("\n");
  printf("Postorder\n");
  Postorder(root);
  printf("\n");
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<queue>
using namespace std;
typedef pair<pair<int,int>,int> pa;
#define ff first.first
#define fs first.second

int h,w,sx,sy,gx,gy;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
int co[21][21];
char ma[21][21];
bool visited[21][21];
string pat;
int m = 999999;

int main(){
    while(cin>>h>>w,h){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                co[i][j]=m;
                cin>>ma[i][j];
                if(ma[i][j]=='A')
                    sx=j,sy=i;
                else if(ma[i][j]=='B')
                    gx=j,gy=i;
            }
        }
        queue<pa>q;
        q.push(make_pair(make_pair(sx, sy), 0));
        while(q.size()){
            pa p = q.front();
            q.pop();
            if(co[p.fs][p.ff]!=m)
                continue;
            co[p.fs][p.ff]=p.second;
            for(int i=0;i<4;i++){
                int nx=p.ff+dx[i];
                int ny=p.fs+dy[i];
                if(nx>=0&&nx<w&&ny>=0&ny<h&&ma[ny][nx]!='#'&&co[ny][nx]==m)
                    q.push(make_pair(make_pair(nx, ny), p.second+1));
            }
        }
        cin>>pat;
        for(int j=0,go=0;;j++,go++){
            int i=j%pat.length();
            if(co[gy][gx]<=go){
                cout<<go<<" "<<gy<<" "<<gx<<endl;
                break;
            }
            if(go>10000){
                cout<<"impossible"<<endl;
                break;
            }
            if(pat[i]=='8')
                gy--;
            else if(pat[i]=='6')
                gx++;
            else if(pat[i]=='4')
                gx--;
            else if(pat[i]=='2')
                gy++;
            gy=max(0,min(h-1,gy));
            gx=max(0,min(w-1,gx));
        }
    }
}

Measured memory_bytes: 1228
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main() {
    int N, x; cin >> N >> x;
    if(x==1 || x==2*N-1){
        cout << "No" << endl;
        return 0;
    }
    
    cout << "Yes" << endl;
    
    if(N==2){
        for(int i=0; i<3; i++) cout << i+1 << endl;
        return 0;
    }
    
    
    if(x==2){
        vector<int> V = {x+2, x, x-1, x+1};
        int on = 0;
        int cur = 0;
        vector<int> a;
        for(int i=0; i<2*N-1; i++){
            if(i+1<x-1 || i+1>x+2) a.push_back(i+1);
        }
        
        for(int i=0; i<2*N-1; i++){
            if(i<(2*N-2)/2-1 || i>(2*N-2)/2+2) cout << a[cur++] << endl;
            else cout << V[on++] << endl;
        }
        
        return 0;
    }
    
    vector<int> V = {x-1, x, x+1, x-2};
    int on = 0;
    int cur = 0;
    vector<int> a;
    for(int i=0; i<2*N-1; i++){
        if(i+1<x-2 || i+1>x+1) a.push_back(i+1);
    }
    for(int i=0; i<2*N-1; i++){
        if(i<(2*N-2)/2-1 || i>(2*N-2)/2+2) cout << a[cur++] << endl;
        else cout << V[on++] << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, answer;
    cin >> A >> B;
    if (A < 6)
    {
        answer = 0;
    }
    else if (A < 13)
    {
        answer = B / 2;
    }
    else
    {
        answer = B;
    }
    cout << answer << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll x, y;
  cin >> x >> y;

  int ans = 0;
  while (x <= y) {
    x *= 2;
    ++ans;
  }
  cout << ans;
  return 0;
}


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

int main() {
	long long x,ans=0,tmp=0;
        cin>>x;
        tmp=x/500;
        x=x%500;
        ans=tmp*1000;

        tmp=x/5;
        ans=ans+tmp*5;
        cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

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

    string S;
    cin >> S;
    ll ct = 0;
    rep(i, len(S)) ct += S[i] == 'A';
    if(ct == 0 || ct == len(S)) print("No");
    else print("Yes");

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int tate = sc.nextInt();
        int yoko = sc.nextInt();

        if (tate == 1 || yoko == 1) {
        	System.out.println(1);
        }else {

        	int add = (tate % 2) * (yoko % 2);

            long menseki =(long)tate * (long)yoko;

            System.out.println((menseki + (long)add) / 2L);
        }

	}

}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod = 998244353;

const int N = 100005;
int fact[N], invfact[N];
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (((ll) x) * y) % mod;}
inline int powr(int a, ll b){
	int x = 1 % mod;
	while(b){
		if(b & 1) x = mul(x, a);
		a = mul(a, a);
		b >>= 1;
	}
	return x;
}
inline int inv(int a){ return powr(a, mod - 2);}
void pre(){
	fact[0] = invfact[0] = 1;
	for(int i = 1;i < N; i++) fact[i] = mul(i, fact[i - 1]);
	invfact[N - 1] = inv(fact[N - 1]);
	for(int i = N - 2; i >= 1; i--) invfact[i] = mul(invfact[i + 1], i + 1);
	assert(invfact[1] == 1);
}

inline int C(int n, int k){
	if(n < k || k < 0) return 0;
	return mul(fact[n], mul(invfact[k], invfact[n - k]));
}

int dp[305 * 305], dp2[305 * 305];
int odp[305 * 305];
int main(){
	pre();
	dp[0] = dp2[0] = 1;
	int n; sd(n);
	int ans = sub(powr(3, n), sub(mul(3, powr(2, n)), 3));
	int sm = 0;
	for(int i = 1; i <= n; i++){
		int x; sd(x);
		sm += x;
		memcpy(odp, dp, sizeof dp);
		for(int t = 300 * i; t >= 0; t--){
			dp2[t + x] = add(dp2[t + x], dp2[t]);
			dp[t] = add(mul(2, dp[t]), t < x ? 0 : mul(1, dp[t - x]));
		}
	}
	for(int s = (sm + 1) / 2; s < sm; s++){
		ans = sub(ans, mul(3, sub(dp[s], mul(2, dp2[s]))));
		// trace(s, dp[s], dp2[s]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 2048
#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<vector>

using namespace std;
#define MAX_V 10
int N,M;
bool G[MAX_V][MAX_V];
bool used[MAX_V];

// 全頂点を訪問済みならtrue,そうでないならfalse
bool finish(void)
{
  int i;
  for(i=0;i<N;i++)
    if(!used[i])
      return false;
  return true;
}
int dfs(int v)
{
  if(finish()) return 1;
  int sum=0;
  int i;
  for(i=0;i<N;i++)
    {
      if(!G[v][i]) continue;
      if(used[i]) continue;
      used[i]=true;
      sum+=dfs(i);
      used[i]=false;
    }
  return sum;
}

int main(void)
{
  cin>>N>>M;
  int i;
  for(i=0;i<M;i++)
    {
      int a,b;
      cin>>a>>b;
      G[a-1][b-1]=true;
      G[b-1][a-1]=true;
    }
  used[0]=true;
  cout<<dfs(0)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main(){
	ll n;
	cin >> n;
	inpv(a,n);
	ll mx = 0;
	ll cnt = 0;
	for(int i=n-2; i>=0; i--){
		if(a[i]>=a[i+1]){
			cnt++;
		}
		else{
			mx = max(mx, cnt);
			cnt = 0;
		}
	}
	mx = max(mx, cnt);
	cout << mx << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <algorithm>

int map[5][5];
int x,y,z;

bool check(int n){
	for(int i = 1;i <= 3; i++){
		int sum = 0;
		for(int j = 1;j <= 3; j++)
			sum += map[i][j];
		if(sum!=n)	return false;
	}
	for(int j = 1;j <= 3 ; j++){
		int sum = 0;
		for(int i = 1;i <= 3 ; i++)
			sum += map[i][j];
		if(sum!=n)	return false;
	}
	int sum = 0;
	for(int i = 1; i <= 3 ;i++)
		sum += map[i][i];
	if(sum!=n)	return false;
	sum = 0;
	for(int i = 1 ;i <= 3 ;i++)
		sum += map[i][3-i+1];
	if(sum!=n)	return false;
	return true;
}

void Print(){
	for(int i = 1; i <= 3; i++){
		for(int j = 1; j <= 3 ;j++)
			printf("%d ",map[i][j]);
		printf("\n");
	}
}

void func(){
	for(int i = 1; i <= 100; i++){
		map[3][3] = i;
		int sum = i + map[1][1] + map[2][2];
		map[1][3] = sum - map[1][1] - map[1][2];
		map[2][3] = sum - map[1][3] - map[3][3];
		map[2][1] = sum - map[2][2] - map[2][3];
		map[3][1] = sum - map[1][1] - map[2][1];
		map[3][2] = sum - map[1][2] - map[2][2];
		if(check(sum))
			Print();
	}
}

int main() {
	std::cin>>map[1][1]>>map[1][2]>>map[2][2];
	func();
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a=[ list(input()) for _ in range(h)]
mod=int((1e9)+7)
dp=[ [0]*w for _ in range(h+1)]
dp[0][0]=1
for i in range(1,h+1):
    dp[i][0]=int(dp[i-1][0]==1)*int(a[i-1][0]=='.')
    for j in range(1,w):
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])*int(not a[i-1][j]=='#') % mod
print(dp[-1][-1])

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

int caluculate() {
    int N;
    string S;
    cin >> N;
    cin >> S; 
    if (N % 2 == 0) {
        for (int i=0; i < N/2; i++) {
            if (S[i] == S[i+N/2]) {
                continue;
            }
            else {
                return 0;
            }
        }
        return 1;
    }
    else {
        return 0;
    }
}

int main() {
    int result;
    result = caluculate();
    if (result == 1) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n,x,t;
    cin>>n>>x>>t;
    cout<<((n-1)/x+1)*t<<endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define pll pair<ll, ll>
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;

inline int fsp(int x, int k = mod - 2) {
    int res = 1;
    while (k) {
        if (k & 1)
            res = 1ll * res * x % mod;
        x = 1ll * x * x % mod, k >>= 1;
    }
    return res;
}

int n;
map<pll, int> num;
pll now[200200];

int main() {

    cin >> n;
    int aa = 0, bb = 0, cc = 0;
    for (int i = 1; i <= n; ++i) {
        long long x, y, g;
        scanf("%lld%lld", &x, &y);
        if (!x || !y) {
            if (!x && !y)
                ++cc;
            else if (!x)
                ++aa;
            else if (!y)
                ++bb;
            --i, --n;
            continue;
        }
        g = __gcd(abs(x), abs(y));
        if (x < 0)
            x = -x, y = -y;
        x /= g, y /= g;
        num[now[i] = make_pair(x, y)]++;
    }

    int ans = (fsp(2, aa) + fsp(2, bb) - 1) % mod;
    for (int i = 1; i <= n; ++i) {
        if (!num[now[i]])
            continue;
        pll tmp = make_pair(-now[i].second, now[i].first);
        if (tmp.first < 0)
            tmp.first *= -1, tmp.second *= -1;
        int x = num[now[i]], y = num[tmp];
        num[now[i]] = num[tmp] = 0;
        int t = (fsp(2, x) + fsp(2, y) - 1) % mod;
        ans = 1ll * ans * t % mod;
    }

    ans = (ans - 1 + cc) % mod;
    if (ans < 0)
        ans += mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 31748
# coding: utf-8
# Your code here!
N,W=map(int,input().split())

jwels=[]

for _ in range(N):
    jwels.append(list(map(int,input().split())))

dp=[-1]*(W+1)
dp[0]=0

for w,v in jwels:
    for i in range(W+1)[::-1]:
        if dp[i]!=-1 and i+w<=W:
            dp[i+w]=max(dp[i]+v,dp[i+w])
            
print(max(dp))



Measured memory_bytes: 41708
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 100000100;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}


bool prime(ll n) {
	if (n == 1)return false;
	if (n == 2)return true;
	for (int i = 2; i < (int)sqrt(n) + 1;i++) {
		if (n%i == 0)return false;
	}
	return true;
}
vector<ll>sosu;
map<ll, int>mp;
int main() {
	ll N, P;
	cin >> N >> P;
	Eratosthenes();
	/*
	FOR(i, 2, 1000020) {
		if (prime(i))sosu.pb(i);
	}
	*/
	
	if (N == 1) {
		p(P);
		return 0;
	}
	ll x = P;
	if (P == 1) {
		p(1);
		return 0;
	}
	while (x >= 2) {
		for (auto i:sosuu) {
			if (x%i == 0) {
				mp[i]++;
				x /= i;
				break;
			}
			if (i >= (ll)sqrt(P))goto END;
		}
	}
	END:
	ll ans = 1;
	for (auto x : mp) {
		while (x.second / N > 0) {
			ans *= x.first;
			x.second -= N;
		}
	}
	p(ans);
}

Measured memory_bytes: 165600
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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;}

using ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  a = s[0] - '0';
  b = s[1] - '0';
  c = s[2] - '0';
  d = s[3] - '0';
  REP(i,2){
    REP(j,2){
      REP(k,2){
        int ans = a;
        if(i==0) ans += b;
        else ans -= b;
        if(j==0) ans += c;
        else ans -= c;
        if(k==0) ans += d;
        else ans -= d;

        if(ans==7){
          char op1 = "+-"[i];
          char op2 = "+-"[j];
          char op3 = "+-"[k];
          cout<<a<<op1<<b<<op2<<c<<op3<<d<<"=7"<<endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

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

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    REP(i, n){
        cin >> v[i];
    }

    int ans = 0;
    IFOR(left, 0, n){
        IFOR(right, 0, min(n-left, k-left)){
            vector<int> youso;
            REP(i, left)
                youso.push_back(v[i]);
            FOR(i, n-right, n)
                youso.push_back(v[i]);
            int rest = k - (left + right);
            sort(youso.begin(), youso.end());
            int now = accumulate(youso.begin(), youso.end(), 0);
            REP(i, min(left+right, rest)){
                if(youso[i] < 0)
                    now -= youso[i];
            }
            ans = max(ans, now);
        }

    }

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

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int s = sc.nextInt();
    int ans = 0;
    for (int x = 0; x <= k; x++) {
      for (int y = 0; y <= k; y++) {
        int z = s - (x + y);
        if (z >= 0 && z <= k) {
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23124
#include <cstdio>
using ll = long long;
constexpr ll off = 1ll << 58;
int n;
ll x[100005], y[100005];
inline bool calc(ll pos)
{
	bool res = false;
	for (int i = 0; i < n; i++)
	{
		ll cur = pos - y[i];
		if (cur >= 0 && cur <= x[i] && (x[i] & cur) == cur)
			res ^= 1;
	}
	return res;
}
int main()
{
	// freopen("C.in", "r", stdin);
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld%lld", x + i, y + i);
		x[i] += off;
	}
	ll ans = 0;
	for (int i = 60; i >= 0; i--)
	{
		if (calc(ans + (1ll << i)))
			ans += 1ll << i;
	}
	printf("%lld\n", ans - off);
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=100005;
//i_am_noob
int n,k,a[maxn],ans=0;
const int K=330;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k;
	a[1]=1;
	rep2(i,2,k+1){
		a[i]=Pow(i,n);
		rep2(j,2,i+1){
			if(i/j<=K) break;
			a[i]=sub(a[i],a[i/j]);
		}
		rep2(j,1,K+1){
			if(j==i) break;
			a[i]=sub(a[i],(i/j-i/(j+1))*a[j]%MOD);
		}
	}
	rep2(i,1,k+1) ans=add(ans,i*a[k/i]%MOD);
	print1(ans);
	return 0;
}

Measured memory_bytes: 4344
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;
 
int main() {
    ll n, a, b; cin >> n >> a >> b;
    vector<ll> h(n);
    rep(i, n) cin >> h.at(i);
 
    sort(h.begin(), h.end());
 
    ll l, r;
 
    l = -1;
    r = (ll)h.at(n-1)/b + 1LL;
    while(abs(r-l)>1){
        ll mid = (l+r)/2LL;
 
        ll tmp = 0;
        for(int i=0; i<n; i++){
            if(h.at(i)-b*mid<=0) continue;
            else{
                tmp += (ll)((h.at(i)-b*mid)+(a-b)-1LL)/(ll)(a-b);
            }
        }
 
        if(tmp>mid) l = mid;
        else r = mid;
    }
 
    cout << r << endl;
 
    return 0;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;


import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long A = sc.nextLong();
			
			System.out.println(A + A * A + A * A * A);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32756
import bisect
n = int(input())
l = list(sorted(map(int, input().split())))


'''
a,bの値を指定し、その合計値を下回る値の最大値のインデックス番号を取得
インデックス番号から指定していたb（大きい方の値）を引く
'''
ans = 0
for a in range(n):
  for b in range(a+1, n):
    ans += bisect.bisect_left(l, l[a]+l[b]) - (b+1)
print(ans)

Measured memory_bytes: 9372
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60;
const ll mod=1000003 ;

struct edge{ll from,to,cost;};

edge es[200020],es2[200020];

ll d[200020],d2[200020];
int V,E;
bool flag;

void shortest_path(int s){
  for(int i=0;i<V;i++)d[i]=longinf;
  d[s]=0;
  while(true){
    bool update=false;
    for(int i=0;i<E;i++){
      edge e=es[i];
      if(d[e.from]!=longinf && d[e.to]>d[e.from]+e.cost && d2[e.from]!=longinf && d2[e.to]!=longinf){
        d[e.to]=d[e.from]+e.cost;
        update=true;
      }
    }
    if(!update)break;
  }
}

void shortest_path2(int s){
  for(int i=0;i<V;i++)d2[i]=longinf;
  d2[s]=0;
  while(true){
    bool update=false;
    for(int i=0;i<E;i++){
      edge e=es2[i];
      if(d2[e.from]!=longinf && d2[e.to]>d2[e.from]+e.cost){
        d2[e.to]=d2[e.from]+e.cost;
        update=true;
      }
    }
    if(!update)break;
  }
}

bool find_negative_loop(){
  memset(d,0,sizeof(d));
  rep(i,2*V){
    rep(j,E){
      edge e=es[j];
      if(d2[e.from]<longinf && d2[e.to]<longinf && d[e.to]>d[e.from]+e.cost){
        d[e.to]=d[e.from]+e.cost;
        if(i==2*V-1)return true;
      }
    }
  }
  return false;
}

int main(){
  ll n,m;
  cin >> n >> m;
  ll x[m],y[m],z[m];
  rep(i,m){
    cin >> x[i] >> y[i] >> z[i];
    x[i]--,y[i]--;
    es[i]={x[i],y[i],-z[i]};
    es2[i]={y[i],x[i],1};
  }
  V=n;
  E=m;
//  rep(i,m){
//    cout << es2[i].from << ' ' << es2[i].to << ' ' << es2[i].cost << endl;
//  }
  shortest_path2(n-1);
//  rep(i,V)cout << d2[i] << ' ' << i << endl;
  if(find_negative_loop()){
    cout << "inf" << endl;
    return 0;
  }
  shortest_path(0);
  cout << -d[n-1] << endl;
return 0;}

Measured memory_bytes: 4864
local str = io.read("*l")
local len = string.len(str)
local first = string.sub(str,1,1)
if first ~= 'A' then
	print("WA")
	return
end
local mid = string.sub(str,3,len-1)
local c = string.find(mid,"C")
if not c then
	print("WA")
	return
end
local rem1 = string.sub(str,2,c+1)
local rem2 = string.sub(str,c+3,len)
if string.match(rem1,"%u") or string.match(rem2,"%u") then
	print("WA")
	return
end
print("AC")

Measured memory_bytes: 760
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

const int N=2001;
int le[N][N];
int ri[N][N];
int up[N][N];
int down[N][N];
char grid[N][N];

int main()
{      
  fastio();
  int n,m,i,j,t;
  cin>>n>>m;
  for(i=0;i<n;i++)
  {
  	for(j=0;j<m;j++)
  	{
  		cin>>grid[i][j];
  	}
  }
  // for left and right
  for(i=0;i<n;i++)
  {
  	for(j=1;j<m;j++)
  	{
  		if(grid[i][j-1]=='#')
  			le[i][j]=0;
  		else
  			le[i][j]=le[i][j-1]+1;
  	}
  	for(j=m-2;j>=0;j--)
  	{
  		if(grid[i][j+1]=='#')
  			ri[i][j]=0;
  		else
  			ri[i][j]=ri[i][j+1]+1;
  	}
  }

  // for up and down
  for(j=0;j<m;j++)
  {
	  for(i=1;i<n;i++)
	  {
	  	if(grid[i-1][j]=='#')
	  		up[i][j]=0;
	  	else
	 		up[i][j]=up[i-1][j]+1;
	  }
	  for(i=n-2;i>=0;i--)
	  {
	  	if(grid[i+1][j]=='#')
	  		down[i][j]=0;
	  	else
	  		down[i][j]=down[i+1][j]+1;
	  }
  }
  int ans=0;
  for(i=0;i<n;i++)
  {
  	for(j=0;j<m;j++)
  	{
  		if(grid[i][j]!='#')
  		{
  			ans=max(ans,le[i][j]+ri[i][j]+up[i][j]+down[i][j]+1);
  		}
  	}
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 66688
// 2014/01/28 Tazoe

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int W, H, N;
	cin >> W >> H >> N;

	int sum = 0;

	int X, Y, A, B;
	cin >> A >> B;

	for(int i=1; i<N; i++){
		cin >> X >> Y;

		int dx = X-A;
		int dy = Y-B;

		if(dx*dy<0){
			sum += (abs(dx)+abs(dy));
		}
		else{
			sum += max(abs(dx), abs(dy));
		}

		A = X;
		B = Y;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1160
n = int(input())
s = input()
c = 0
for i in range(1000):
  num = str(i).zfill(3)
  if num[0] in s:
    k = s[(s.find(num[0])+1):]
    if num[1] in k:
      d = k[(k.find(num[1])+1):]
      if num[2] in d:
        c += 1
print(c)

Measured memory_bytes: 3188
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <iomanip>
#include <cassert>
#include <numeric>
using namespace std;
 
#define ff first
#define ss second
#define pb push_back 
 
using LL = long long int;
using VL = vector<LL>;
using VI = vector<int>;
using VVL = vector<VL>;
using PLL = pair<LL,LL>;
using PII = pair<int ,int>;
 
#ifdef DEBUG
void _print()
{
  cout << endl;
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
  cout << first_elem << " ";
  _print(args...);
}
#else
void _print()
{
}
template<typename T, typename... Args >
void _print(const T first_elem, const Args... args)
{
}
#endif
 
 
// NOTE: Please dont implement _print() as function in your program. It is reserved
// for debug purpose.

int main()
{
    ios::sync_with_stdio(false);
    LL n;
    cin >> n;
    LL mod = 1e9 + 7;
    LL sum = 0;
    LL ans = 0;
    VL a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ans = (ans + (a[i] * sum) % mod) % mod;
        sum = (sum + a[i]) % mod;
    }

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

Measured memory_bytes: 4468
N, A, B, C, D = map(int, input().split())
 
S = input()
 
S = S + '#'
 
def continuous_rock_search(S, A, B, C, D):
    begin = min(A, B)
    target = max(C, D)
    for i in range(begin, target - 1):
        if S[i] == '#' and S[i+1] == '#':
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '#' or S[B] == '#'):
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S, A, B, C, D):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(S, A, B, C, D):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3512
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;


int main(int argc, char* argv[])
{
    int n,Q;
    scanf("%d%d", &n, &Q);

    vector<pair<pair<ll, int>, int> > z;   // x, type(0:left, 1:right, 2:que), id

    vector<ll> s(n), t(n), x(n); 
    int i;
    for(i=0; i<n; i++) {
        scanf("%lld%lld%lld", &s[i], &t[i], &x[i]);
        s[i]-=x[i];
        t[i]-=x[i];
        z.push_back( make_pair(make_pair(s[i], 0), i));
        z.push_back( make_pair(make_pair(t[i], 1), i));
    }
    vector<ll> d(Q);
    for(i=0; i<Q; i++) {
        scanf("%lld", &d[i]);
        z.push_back( make_pair(make_pair(d[i], 2), i));
    }
    sort(z.begin(), z.end());
    
    vector<ll> ans(Q);
    set<pair<ll, int> > ss;
    for(i=0; i<(int)z.size(); i++) {
        int type = z[i].first.second;
        int id=z[i].second;
        if(type==0) {            
            ss.insert(make_pair(x[id], id));
        }
        else if(type==1) {
            ss.erase(make_pair(x[id], id));
        }
        else {
            if(ss.empty()) {
                ans[id]=-1;
            }
            else {
                ans[id]=(*ss.begin()).first;
            }
        }
    }
    for(i=0; i<Q; i++) {
        printf("%lld\n", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 35940
// Problem : A - A?C
// Contest : AtCoder - AtCoder Beginner Contest 166
// URL : https://atcoder.jp/contests/abc166/tasks/abc166_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define sqr(x) (x) * (x)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ALL(a) a.begin(), a.end()
#define rALL(a) a.rbegin(), a.rend()
#define SORT(a) sort(ALL(a))
#define sc scanf
#define pr printf
#define xatop(a) cerr << #a << " = " << a << endl;
#define jsatr xatop(__LINE__)
#define INF 1000000000
#define mod 1000000007

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

	cout << (s == "ABC" ? "ARC" : "ABC") << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << ((a*b>c*d)?a*b:c*d) << endl;
}

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

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

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
const int INF = 1e9;
const llint llINF = 1e18;

int main () {
    int n; cin >> n;
    vint l(n);
    rep(i, n) cin >> l[i];
    sort(all(l));
    int max = l[n - 1];
    int sum = 0;
    for (int i = 0; i < n - 1; i++) {
        sum += l[i];
    }
    if (max >= sum) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b<c){
        cout << "NA" << endl;
    }
    else if(a<c){
        cout << c-a << endl;
    }
    else if(a>c){
        cout << "0" << endl;
    }
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define infll 0x7fffffffffffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=998244353;
const int M=1e6+10;
const int N=3e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int T,n,m;
int ans;
int a,b,c,d;
int main()
{
    int i,j,k;
	ans=0;
	n=read();
	bool f=0;
	a=read(),b=read();
	for(i=a;i<=b;i++) {
		if(i%n==0) f=1;
	}
	
	if(f) printf("OK");
	else printf("NG");
	printf("\n");
    return 0;
}


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

using namespace std; 

int main(){ 
  set<char> a;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    a.insert(s.at(i));
  }
  if(a.size()==s.size()) cout<<"yes";
  else cout<<"no";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>vec;
int  ara[303][303];
int ret=0;

int main()
{
    int i,j,t,n,a,b,c;
    cin>>t;
    a=t%1000;
    if(a==0)
        cout<<"0"<<"\n";
    else
        cout<<1000-a<<"\n";

return 0;
}


Measured memory_bytes: 3640
'use strict';
const main = arg => {
  const input = arg.trim().split('\n');
  const arr = input.map(a => a.split(' '));
  // console.log(arr);
  const N = arr[0][0];

  let rowArray = [];
  // console.log(arr.length)
  for (let i=2; i<arr.length; i+=2) {
    rowArray.push(arr[i]);
    // console.log(arr[i]);
  }
  // console.log(rowArray.flat());

  const set = new Set(rowArray.flat());
  const AnswerArr = Array.from(set);

  console.log(N - AnswerArr.length);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30432
#include<bits/stdc++.h>
using namespace std;
const int N=2010,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int n,k,dp[N][N];
//dp[i][j]表示两个单调序列最后一个删掉的分别是i,j的方案数
int main()
{
    cin>>n>>k;
    dp[n+1][n+1]=1;
    for (int i=n+1;i;i--)
    for (int j=1;j<=i;j++){//钦定i>=j
        dp[i][j]=inc(dp[i][j],dp[i][j-1]);
        int v=dp[i][j];
        if (!v) continue;
        dp[i-1][1]=inc(dp[i-1][1],v);dp[i-1][j]=dec(dp[i-1][j],v);
        if (i!=j) dp[i-1][j]=inc(dp[i-1][j],v),dp[i-1][j+1]=dec(dp[i-1][j+1],v);
    }
    int ans=0;
    for (int i=2;i<=n+2-k;i++) ans=inc(ans,dp[n+2-k][i]);
    for (int i=1;i<n-k;i++) ans=inc(ans,ans);
    printf("%d\n",ans);
    return 0;
}


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

int main(){
  double l; cin >> l;
  double v = (l*l*l) / 27;
  
  cout << fixed << setprecision(10);
  cout << v << endl;
  
  return 0;
}


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

typedef long long ll;

int main(){
  ll a;
  cin>>a;
  ll l;
  for(l=2;l/2*(l/2+1)/2<a;l+=2);
  string s(l,'(');
  for(int i=0;i<=l/2;i++){
    s[i]=')';
  }
  s[0]='(';
  l-=2;
  a-=l/2*(l/2+1)/2;
  // cout<<a<<endl;
  for(int i=0;a>0;i++){
    a--;
    swap(s[i],s[i+1]);
  }
  cout<<s<<endl;








  return 0;
}



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

int main(){
    int t,n;
    cin>>n;
    int bj = 0;
    t = 0;
    for(int i = 0;i < n;i++){
        int a,b;
        cin>>a>>b;
        if(a == b)t++;
        else t = 0;
        if(t >= 3)bj = 1;
    }
    if(bj == 1)cout<<"Yes"<<"\n";
    else cout<<"No"<<"\n";
   // system("PAUSE");
    return 0;
}

Measured memory_bytes: 3620
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  std::string S; std::cin >> S;
  int max_cnt = 0;
  int cnt = 0;
  for (char c : S) {
    if (c == 'A' || c == 'T' || c == 'C' || c == 'G') {
      ++cnt;
    } else {
      max_cnt = std::max(max_cnt, cnt);
      cnt = 0;
    }
  }
  max_cnt = std::max(max_cnt, cnt);
  std::cout << max_cnt << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod =1e9+7;
#define MAX 1000005
ll f[MAX];
ll iv[MAX];
ll poer(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=(res*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void in_it(){
	f[0]=1;
	iv[0]=1;
	for(int i=1;i<MAX;++i) f[i]=(f[i-1]*i)%mod;
	iv[MAX-1]=poer(f[MAX-1],mod-2);
	for(int i=MAX-2;i>=0;--i) iv[i]=(iv[i+1]*(i+1))%mod;
}
ll C(ll n, ll r){
	if(n<r) return 0;
	ll ans=(f[n]%mod*iv[r]%mod)%mod;
	ans =(ans*iv[n-r]%mod)%mod;
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
	in_it();
	ll h,w,a,b;
	cin>>h>>w>>a>>b;
	ll ans=0;
	for(int i=b;i<w;++i){
		ll x1=i;
		ll y1=h-a-1;
		ll term1=C(x1+y1,x1);
		ll x2=w-1-i;
		ll y2=a-1;
		ll term2=C(x2+y2,y2);
		term1%=mod;
		term2%=mod;
		ans=(ans+(term1*term2)%mod)%mod;
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 19236
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))

cs = [0] * (N + 1)
csdict = {}
csdict[0] = 1

for i in range(N):
    cs[i + 1] = cs[i] + A[i]
    if csdict.get(cs[i + 1]) == None:
        csdict[cs[i + 1]] = 1
    else:
        csdict[cs[i + 1]] += 1

# print(cs)
# print("")
# print(csdict)

total = 0
for mykey, myvalue in csdict.items():
    if myvalue >= 2:
        total = total + ((myvalue * (myvalue-1))//2)

print(total)


Measured memory_bytes: 40524