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

typedef long long ll;
typedef pair<ll,ll> P;

#define fr first
#define sc second

int main(){
	static int n;
	static int a[200010];
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i ++){
		scanf("%d",&a[i]);
	}
	
	ll ret = 0;
	ll l = 0;
	ll pre[20] = {};
	for(int i = 1 ; i <= n ; i ++){
		for(int j = 0 ; j < 20 ; j ++){
			if((a[i]>>j)&1){
				l = max( l , pre[j] );
				pre[j] = i;
			}
		}
		ret += i-l;
	}
	cout << ret << endl;
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

const double pie = acos(-1.0);

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

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

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

const ll MOD = 1e9 + 7;

void solve() {
    ll n; cin >> n;
    Vs vs(n);
    rep(i, 0, n) cin >> vs[i];
    rep(i, 0, 26){
        char c = 'a' + i;
        ll cnt = 100100;
        rep(j, 0, n){
            ll m = count(ALL(vs[j]),char('a'+ i));
            cnt = min(cnt, m);
        }
        rep(j, 0, cnt) cout << char('a' + i);
    }
    cout << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
now_x = 0
now_y = 0
now_t = 0
for i in range(N):
    t,x,y = map(int, input().split())
    margin = (t- now_t) - abs(x - now_x) - abs(y - now_y)
    if margin < 0 or margin%2!=0:
        print("No")
        break
    else:
        now_x = x
        now_y = y
        now_t = t
else:
    print("Yes")

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  = 3.141592653589793238463;
const int N = 1e5+10;
const ll INF = 1LL << 60;

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


// Main Code
map<int, int> mp;
int main()
{
	int n, k;
	cin>>n>>k;
	repn(i, 1, n)
	{
		int z = i % k;
		mp[z]++;
	}
	ll ans = 0;
	ll nn = mp[0];
	ans = nn + nn*(nn-1)*3 + nn*(nn-1)*(nn-2);

	if((k&1) == 0)
	{
		nn = mp[k/2];
		ans += nn + nn*(nn-1)*3 + nn*(nn-1)*(nn-2);;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, s, n) for(ll i = s; i < n; i++)
using namespace std;

int main(){
  ll n;
  cin >> n;
  ll x = 0;
  ll y = 100000000000000;
  rep2(i, 1, sqrt(n)+1){
    if (n % i == 0){
      if (i + n/i < x + y){
        x = i;
        y = n/i;
      }
    }
  }
  cout << x + y - 2 << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <stack>
#define pb push_back
#include <functional>
#include <vector>
#include <queue>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
using namespace std;
int n,m;
vector<pii> G[52];
int fr=1;
int road[52][52];
int e[52][52];
int v[52];
int main()
{
	int a;
	int ans = 0;
	scanf("%d%d",&n,&m);
	rep(i,0,10){
		rep(j,0,10){
			scanf("%d",&e[i][j]);
		}
	}
	for(int k=0;k<10;k++)
	for(int i=0;i<10;i++)
		for(int j=0;j<10;j++)
			e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
	rep(i,1,n+1){
		rep(j,1,m+1){
			scanf("%d",&a);
			if(a!=-1) ans+=e[a][1];
		}
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
		int D, G;
		cin >> D >> G;
		int p[D], c[D];
		for (int i = 0; i < D; i++) {
				cin >> p[i] >> c[i];
		}

		int ans = 1e9;

		for (int comp = 0; comp < (1<<D); comp++) {

				int score = 0, solved = 0, not_soleved = 0;

				for (int i = 0; i < D; i++) {
						if (comp & (1<<i)) {
								score += c[i] + (i+1) * 100 * p[i];
								solved += p[i];
						} else {
								not_soleved = i;
						}
						
				}

				if (G > score) {
						int t = (not_soleved+1) * 100;
						int need = (G-score+t-1) / t;
						if (need >= p[not_soleved]) continue;
						solved += need;
				}

				ans = min(ans, solved);
		}

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


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

int n,k,goukei,o[100003];
double seikai;
int y=0;
int maxpi;
double kakuritsu;
int main(){
    cin>>n>>k;
    for (int i=1; i<=n; i++) {
        goukei=i;
        y=0;
        while (goukei<k) {
            goukei*=2;
            y++;
        }
        maxpi=max(y,maxpi);
        o[i]=pow(2,y)*n;
    }
    int r=pow(2,maxpi);
    for (int i=1; i<=n; i++) {
        seikai+=r*n/o[i];
    }
    cout<<setprecision(15)<<seikai/(r*n)<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

typedef long long ll;

const ll MAX_N = 1010;

int main(int argc, char const *argv[]) {
  ll n, m, x[MAX_N], y[MAX_N], z[MAX_N];
  cin >> n >> m;
  for (size_t i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];

  ll ans = 0;
  
  for (int bi = 0; bi < (1<<3); ++bi)
  {
  	bitset<3> bs(bi);
  	vector<ll> vec; 
  	for (int i = 0; i < n; ++i)
  	{
  		ll temp = 0;
  		if (bs[0]==0) temp -= x[i];
  		else temp += x[i];
  		if (bs[1]==0) temp -= y[i];
  		else temp += y[i];
  		if (bs[2]==0) temp -= z[i];
  		else temp += z[i];

  		vec.push_back(temp);
  	}
  	sort(vec.begin(), vec.end());
  	reverse(vec.begin(), vec.end());
  	ll sum = 0;
  	for (int i = 0; i < m; ++i) {
  		sum += vec[i];
  	}
  	ans = max(ans, sum);
  }

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


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int n,m,a,h,hmax,p,q,i,j,c;
  int x[1001][101];

  while(1){
    for(i=1;i<=1000;i++){
      for(j=1;j<=100;j++){
	x[i][j]=0;
      }
    }
    hmax=0;
    c=1;
    scanf("%d %d %d",&n,&m,&a);
    if(n==0&&m==0&&a==0)break;
    if(m!=0){
      for(i=0;i<m;i++){
	scanf("%d %d %d",&h,&p,&q);
	if(h>hmax)hmax=h;
	x[h][p]=c;
	x[h][q]=c;
	c++;
      }
    }
    for(i=hmax;i>0;i--){
      if(x[i][a]!=0){
	if(a==1&&x[i][a+1]==x[i][a])a++;
	else if(a==n&&x[i][a-1]==x[i][a])a--;
	else if(x[i][a-1]==x[i][a])a--;
	else if(x[i][a+1]==x[i][a])a++;
      }
    }
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll h, w, k;
  cin >> h >> w >> k;
  vector<vector<ll>> c(h, vector<ll>(w, 0));
  REP(i, h) {
    string s;
    cin >> s;
    REP(j, w) {
      if (s[j] == '#') {
        c[i][j] = 1;
      }
    }
  }
  ll ans = 0;
  REP(r, 1LL << h) REP(col, 1LL << w) {
    vector<bool> tate(h, false), yoko(w, false);
    REP(i, h) {
      if ((1LL << i) & r) {
        tate[i] = true;
      }
    }

    REP(i, w) {
      if ((1LL << i) & col) {
        yoko[i] = true;
      }
    }
    ll cnt = 0;
    REP(i, h) REP(j, w) {
      if (tate[i] && yoko[j] && c[i][j]) {
        cnt++;
      }
    }
    if (cnt == k) {
      ans++;
    }
  }
  cout << ans << endl;
}

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

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    int n,k;
    cin >> n >> k;
    vector<double> p(n);
    for(int i=0;i<n;i++){
        double a;
        cin >> a;
        double sum=(1+a)/2;
        p[i]=sum;
    }
    double ans=0;
    for(int i=0;i<k;i++){
        ans+=p[i];
    }
    double temp=ans;
    for(int i=k;i<n;i++){
        temp=temp+(p[i]-p[i-k]);
        ans=max(ans,temp);
    }
    printf("%.10lf\n",ans);
    return 0;

}

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

#define FOR(i, s, e)   for(int i = (s); i < (e); i++)
#define FOR64(i, s, e) for(ll  i = (s); i < (e); i++)
#define ALL(x)         (x).begin(), (x).end()
#define SORT(b, e)     sort((b), (e))
#define REV(b, e)      reverse((b), (e))
#define VSORT(v)       sort((v).begin(), (v).end())
#define VREV(v)        reverse((v).begin(), (v).end())
#define pb(a)          push_back(a)
#define INF            999999999

typedef long long ll;

int main()
{
	int A, B;
	cin >> A >> B;

	if(A * B % 2 == 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}



Measured memory_bytes: 256
//
// Created by Harshit on 20-08-2020.
//

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector <int> height(n);
    vector <int> resarr(n+1,INT_MAX);
    resarr[1]=0;
    for(int i=0;i<n;i++)
        cin>>height[i];

    for(int i=1;i<=n-1;i++){
        resarr[i+1]=min(resarr[i+1],resarr[i]+abs(height[i]-height[i-1]));
        if(i+2<=n)
            resarr[i+2]=min(resarr[i+2],resarr[i]+abs(height[i+1]-height[i-1]));
    }
   cout<<resarr[n]<<endl;

}

Measured memory_bytes: 3920
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(r: int):
    print(r**2)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))  # type: int
    solve(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	map<int,int> mp;
	int n;
	vector<int> vec;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		mp[a]++;
	}
	for(auto it = mp.begin();it != mp.end();it++){
		if(it->second >= 2) vec.push_back(it->first);
		if(it->second >= 4) vec.push_back(it->first);
	}
	if(vec.size() <= 1){
		cout << 0 << endl;
		return 0;
	}
	sort(all(vec),greater<int>());
	cout << vec[0] * vec[1] << endl;
	return 0;
}

Measured memory_bytes: 6528
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)

	var cnt int

	for i := 1; i <= N; i++ {
	L:
		for j := 1; j <= N; j++ {
			if i*j >= N {
				break L
			}
			temp := N - (i * j)
			if temp > N {
				continue
			}
			if temp <= 0 {
				continue
			}
			cnt++
		}
	}

	fmt.Println(cnt)
}


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

int main() {
	int n, k, ans = 1;
	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		if (ans < k) {
			ans *= 2;
		}
		else {
			ans += k;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scanln(&n)

	var sc = bufio.NewScanner(os.Stdin)

	sc.Split(bufio.ScanWords)
	invSum := 0.0
	for i := 0; i < n; i++ {
		if sc.Scan() {
			valueFloat, _ := strconv.ParseFloat(sc.Text(), 64)
			invSum += 1 / valueFloat
		}
	}

	fmt.Println(1 / invSum)

}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  map<string,int> p;
  rep(i,n){
  string s;
  cin>>s;
    if(p.count(s)) p.at(s)++;
    else p[s]=1;
  }
  
  int ma=0;
  for(auto t : p) {
    ma=max(ma,t.se);
  }
  
  vector<string> q;
  for(auto t : p) {
    if(ma==t.se) q.pb(t.fi);
  }
  
  sort(all(q));
  
  rep(i,q.size()){
  cout << q[i] << endl;
  }
    
}

Measured memory_bytes: 26868
#include <stdio.h>
int i;
int count=0;


void Binary(int *A,int key){
  int left=0,right;
  int mid;

  right=i;
  while(left < right){
    mid=(left+right)/2;
    
    if(key == A[mid]){
      count++;
      return ;
    }
    if(key > A[mid]) left = mid + 1;
       else if(key < A[mid]) right=mid;
       
       
  }
   
}

main(){


  int A[100000],t,j,q,n;


  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
 for(j=0;j<q;j++){

   scanf("%d",&t);
   Binary(A,t);
 }


 printf("%d\n",count);
 return 0; 
}

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

int main() {
  
  int h, n;
  int a = 0;
  
  cin >> h >> n;
  
  for(int i = 0; i < n; i ++){
    cin >> a;
    h = h - a;
    if (h <= 0){
      cout << "Yes" << endl;
      break;
    } else if (i == n - 1){
cout << "No" << endl;
    }
  }
  
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll n=in();
    vector<ll>v(n);
    for(ll i=0;i<n;++i)v[i]=in();
    sort(v.begin(),v.end());
    priority_queue<ll>pq;
    pq.push(*v.rbegin());
    v.pop_back();
    ll ans=0;
    for(ll i=n-2;i>=0;--i){
        ans+=pq.top();pq.pop();
        pq.push(v[i]);
        pq.push(v[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6932
/* author:hellojim */
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
ll dp[2020][2020];
ll sum[2020][2020];
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	int n;
	cin>>n;
	if(n<=2)
	{
		cout<<0<<endl;
		return 0;
	}
	ll ans=0;
	memset(dp,0,sizeof(dp));
	memset(sum,0,sizeof(sum));
	rep(i,n+1)sum[0][i]=1;
	dp[0][0]=1;
	for(int i=1;i<=1000;i++)
	{
		if(i*3>n)break;
		for(int j=3;j<=n;j++)
			dp[i][j]=sum[i-1][j-3];
		sum[i][0]=dp[i][0];
		for(int j=1;j<=n;j++)
			sum[i][j]=(sum[i][j-1]+dp[i][j]+mod)%mod; 
	}
	for(int i=1;i<=1000;i++)ans=(ans+dp[i][n])%mod;
	cout<<ans<<endl; 
	return 0;
}



Measured memory_bytes: 67400
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define ipair pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int arr[1000001],cnt[1000001];

int32_t main()
{
  int n;
  cin>>n;
  int arr[n][2];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i][0]>>arr[i][1];
  }
  vector<double> v;
  for(int i=0;i<n;i++)
  {
    for(int j=i;j<n;j++)
    {
      int x=abs(arr[i][0]-arr[j][0]);
      int y=abs(arr[i][1]-arr[j][1]);
      x=x*x;
      y=y*y;
      double z=x+y;
      z=sqrt(z);
      v.pb(z);
    }
  }
  int fact=1,facti=1;
  for(int i=1;i<=n;i++)
  {
    fact=fact*i;
  }
  //facti=fact/n;

  double sum=0;
  for(int i=0;i<v.size();i++)
  {
    sum+=v[i];
  }
  sum=sum*2;
  sum=sum/n;
  cout<<fixed<<setprecision(6)<<sum;
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*4
#define REP(a,b) for(long long a = 0;a < b;++a)
long long dp[4000][4000];
int main(){
	int n, query;
	cin >> n >> query;
	vector<long long> geko;
	REP(i, n) {
		long long a;
		cin >> a;
		geko.push_back(a);
	}
	REP(i, n) {
		REP(q, n) {
			if (i != q) {
				dp[i][q] = (geko[i] > geko[q]);
			}
		}
	}
	long long nya = 1;
	for (int i = 0; i < query; ++i) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		long long hoge = dp[a][b] + dp[b][a];
		hoge *= GYAKU;
		hoge %= MAX_MOD;
		dp[a][b] = hoge;
		dp[b][a] = hoge;
		for (int j = 0; j < n; ++j) {
			if (a == j || b == j) continue;
			long long neko = dp[a][j] + dp[b][j];
			neko *= GYAKU;
			neko %= MAX_MOD;
			dp[a][j] = neko;
			dp[b][j] = neko;
			neko = dp[j][a] + dp[j][b];
			neko *= GYAKU;
			neko %= MAX_MOD;
			dp[j][a] = neko;
			dp[j][b] = neko;
		}
		nya *= 2LL;
		nya %= MAX_MOD;
	}
	long long ans = 0;
	REP(i, n) {
		for (int q = i+1; q < n; ++q) {
			ans += dp[i][q] * nya;
			ans %= MAX_MOD;
		}
	}
	cout << ans << endl;
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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 P = pair<int,int>;
//Write From this Line

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

	if(a <= 0 && 0 <= b){
		cout << "Zero" << endl;
		return 0;
	} else if(0 < a){
		cout << "Positive" << endl;
		return 0;
	} else {
		ll num = b -  a + 1;
		if(num % 2 == 0){
			cout << "Positive" << endl;
		}
		else {
			cout << "Negative" << endl;
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#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()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int cnt =0;
  rep(i,s.length()-1)
  {
    if(s[i]!=s[i+1])cnt++;
  }
  cout<<cnt<<endl;
  return 0;

}


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

#define N 1299710

using namespace std;

int main(){
	bool prime[N];
	for (int i = 0; i < N; i++) prime[i] = 1;
	prime[1] = 0;
	for (int i = 1; i < sqrt(N); i++) {
		if (!prime[i]) continue;
		else {
			for (int j = 2; i * j < N; j++) prime[i * j] = 0;	
		}
	}

	int k;
	while (cin >> k, k) {
		if (prime[k]) {
			cout << "0" << endl;	
		} else {
			int a, b;
			for (a = k; !prime[a]; a--);
			for (b = k; !prime[b]; b++);
			cout << b - a << endl;
		}	
	}
	return 0;
}

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

int main( void )
{
  int N, K;
  cin >> N >> K;

  long long int ans = 1;
    
  ans = K;
  
  if( N != 1 )
    for( int i = 0; i < N - 1; i++ )
	ans *= ( K - 1 );

  cout << ans << endl;
}

Measured memory_bytes: 3532
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()
n, k = [int(i) for i in input().split()]
e = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = [int(i) for i in input().split()]
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)
ans = 1
mod = 10**9+7
 
 
def dfs(i=0, r=-1):
    global ans
    if r == -1:
        ans *= k
        ans %= mod
 
        p = k-1
        for j in e[i]:
            if j == r:
                continue
            ans *= p
            ans %= mod
            p -= 1
            dfs(j, i)
    else:
        p = k-2
        for j in e[i]:
            if j == r:
                continue
            ans *= p
            ans %= mod
            p -= 1
            dfs(j, i)
 
 
dfs()
print(ans)

Measured memory_bytes: 101424
#include <bits/stdc++.h>
#define LL long long
using namespace std;

LL n,a,b;
LL mod=1000000007;

LL poww(LL n,LL a)
{
     LL base = n;
     LL ans=1;
     while(a>0)
     {
         if(a&1)
            ans*=base,ans%=mod;
        base=base*base%mod;
        a>>=1;
     }
     return ans;
}

LL C(LL n,LL m) 
{
    if(n < m) return 0;
    LL res = 1;
    for(int i=1; i<=m; i++) {
        LL a = (n+i-m)%mod;
        LL b = i%mod;
        res = res*(a*poww(b,mod-2)%mod)%mod;
    }
    return res;
}

LL Lucas(LL n,LL m) 
{
    if(m == 0) return 1;
    return C(n%mod, m%mod) * Lucas(n/mod,m/mod)%mod;
}

int main()
{
    cin>>n>>a>>b;
    LL ans=poww(2,n)-1;
    ans=ans-Lucas(n,a)-Lucas(n,b);
    while(ans<0)
        ans+=mod;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int x, s = 0, tmp;
  	scanf("%d", &x);
  	tmp = x;
  	while (tmp) {
      	s += tmp % 10;
      	tmp /= 10;
    }
  	if (x % s == 0)
      	puts("Yes");
  	else
      	puts("No");
  	return 0; 
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAXN=1e5+1+5;
int N,p[MAXN];

int main() {
        cin >> N;
        for (int i=1; i<=N; i++)
                cin >> p[i];

        int ct=0;
        for (int i=1; i<=N-1; i++) {
                if (p[i] == i) {
                        swap(p[i],p[i+1]);
                        ct++;
                }
        }

        if (p[N] == N)
                ct++;

        cout << ct << "\n";
}

Measured memory_bytes: 640
S = input()
T = input()

s = len(S)
t = len(T)

ans = []
for i in range(s - t + 1):
    flg = 0
    for j in range(t):
        if S[i+j] == T[j]:
            pass
        elif S[i+j] == '?':
            pass
        else:
            flg = 1
            break
    if flg == 0:
        ans.append(S[0:i].replace('?', 'a') + T + S[i+t:].replace('?', 'a'))
if len(ans) == 0:
    print('UNRESTORABLE')
else:
    print(sorted(ans)[0])


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define ll long long
#define mod 1000000007

int main () {
  ll h, w;
  cin >> h >> w;
  string s[1001];
  ll dp[h][w];
  for (ll i = 0; i < h; i++) {
    cin >> s[i];
    for (ll j = 0; j < w; j++) dp[i][j] = 0; 
  }
  dp[0][0] = 1;
  ll vx[2] = {-1, 0};
  ll vy[2] = {0, -1};
  for (ll i = 0; i < h; i++) {
    for (ll j = 0; j < w; j++) {
      for (ll l = 0; l < 2; l++) {
        ll x = j + vx[l];
        ll y = i + vy[l];
        if (s[i][j] == '.' && s[y][x] == '.' && x >= 0 && x < w && y >= 0 && y < h) {
          dp[i][j] = (dp[i][j] + dp[y][x]) % mod;   
        }    
      }
    }  
  }
  cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 9600
//author:pranta
//date: "2020-08-02"
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
void solve()
{
    int n,d,c=0;
    cin>>n>>d;
    while(n--){
        double x,y;
        cin>>x>>y;
        double ans=sqrt(x*x+y*y);
        //cout<<ans<<endl;
        if(ans<=d) c++;
    }
    cout<<c<<endl;
}
int main()
{
    fast;
    int t;
    solve();
}

Measured memory_bytes: 3788
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
    ll a[10];
    ll i,s=0;
    for(i=1;i<=5;i++)
    {
        cin>>a[i];
        if(a[i]==0)
        {
            s=i;
        }
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
	
	
	System.out.println(c + " " + a + " " + b);
	}
}

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

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define EPS 1e-14
#define INF 1<<30
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back

#define fi first
#define se second

#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

typedef long long ll;

const int N = 1e5 + 10;
vector<pair<int,int> > g[N];
int x[N];
bool ok = true;

void dfs(int v){
	for(auto& uu : g[v]){
		int u = uu.fi;
		int d = uu.se;
		if(x[u] == INF){
			x[u] = x[v] + d;
			dfs(u);
		}else if(x[u] != x[v] + d){
			ok = false;
		}
	}
}

int main(){
	int n,m;
	cin >> n >> m;	
	while(m--){
		int l,r,d;
		cin >> l >> r >> d;
		g[l].pb({r,-d});
		g[r].pb({l,d});
	}
	fill(x,x+N,INF);
	REP(i,1,n+1){
		if(x[i] == INF){
			x[i] = 0;
			dfs(i);
		}
	}
	if(ok) cout << "Yes" << endl;
	else     cout << "No"  << endl;
	return 0;
}

Measured memory_bytes: 11008
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  int b[n];
  for (int i=0; i<n-1; i++) {
    scanf("%d", &b[i]);
  }
  long long ans = b[0];
  for (int i=1; i<n-1; i++) {
    ans += min(b[i], b[i-1]);
  }
  ans += b[n-2];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string S = in<string>();
    int red = 0;
    int maxi = S.size();
    REP(i,maxi)if(S[i] == '0')red++;
    cout << min(red,maxi-red) * 2 << "\n";
}

Measured memory_bytes: 512
use whiteread::parse_line;

fn main() {
    let _n: usize = parse_line().unwrap();
    let mut a: Vec<u32> = parse_line().unwrap();
    a.sort();
    let ans = a.iter().fold(a[0] as f64, |x, &y| (x + y as f64) / 2.0);
    println!("{}", ans);
}


Measured memory_bytes: 2188
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>

using namespace std;

int main(void)
{
	string S;
	cin >> S;
	string front = S.substr(0, S.length() / 2);
	string back = S.substr(S.length() / 2);
	int frontInt = 0;
	int backInt = 0; 
	istringstream iss(front);
	iss >> frontInt;
	istringstream iss2(back);
	iss2 >> backInt;

	if (frontInt <= 12 && backInt <= 12 && frontInt > 0 && backInt > 0)
	{
		cout << "AMBIGUOUS";
	}
	else if (backInt <= 12 && backInt > 0)
	{
		cout << "YYMM";
	}
	else if (frontInt <= 12 && frontInt > 0)
	{
		cout << "MMYY";
	}
	else
		cout << "NA";
}



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

int main()
{

    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    if(n==m)
    {

        cout<<"Yes"<<'\n';
    }
    else
    {

        cout<<"No"<<'\n';
    }









}


Measured memory_bytes: 256
#include<iostream>
#include<atcoder/all>

using namespace std;
using namespace atcoder;

int main(){
    long long t, n, m, a, b;
    cin >> t;
    for (int i = 0; i < t;i++){
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  vector<int64_t>B(N);
  for(int i=0;i<N;i++)
    cin>>B.at(i);
  sort(B.begin(),B.end());
  vector<int64_t>C(N);
  for(int i=0;i<N;i++)
    cin>>C.at(i);
  sort(C.begin(),C.end());
  int64_t ans=0;
  for(int i=0;i<N;i++){
  auto itr=lower_bound(A.begin(),A.end(),B.at(i));
    int64_t a=distance(A.begin(),itr);
    auto itr1=upper_bound(C.begin(),C.end(),B.at(i));
    int64_t b=N-distance(C.begin(),itr1);
  ans+=a*b;
  
  }cout<<ans<<endl;
  
   return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#define eol '\n';
using namespace std;

class Node {
public:
  int k;
  Node* p;
  Node* l;
  Node* r;
  Node(): k(-1),p(nullptr),l(nullptr),r(nullptr){};
};

Node* root;

void insert(Node* z) {
  Node* y = nullptr;
  Node* x = root;
  while (x != nullptr) {
    y = x;
    if (z->k < x->k) {
      x = x->l;
    } else {
      x = x->r;
    }
  }
  z->p = y;

  if (y == nullptr) {
    root = z;
  } else if (z->k < y->k) {
    y->l = z;
  } else {
    y->r = z;
  }
}

bool find(int k) {
  Node* x = root;
  while (x != nullptr) {
    if (k == x->k) {
      return true;
    } else if (k < x->k) {
      x = x->l;
    } else {
      x = x->r;
    }
  }
  return false;
}

void inorder(Node* node) {
  if (node == nullptr) {
    return;
  }
  
  inorder(node->l);
  cout << " " << node->k;
  inorder(node->r);
  if (node->p == nullptr) {
    cout << eol;
  }
}

void preorder(Node* node) {
  if (node == nullptr) {
    return;
  }
  cout << " " << node->k;
  preorder(node->l);
  preorder(node->r);
  if (node->p == nullptr) {
    cout << eol;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int m,k;
  string cmd;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> cmd;
    if (cmd == "insert") {
      cin >> k;
      Node* node = new Node();
      node->k = k;
      insert(node);
    } else if (cmd == "find") {
      cin >> k;
      if (find(k)) {
        cout << "yes" << eol;
      } else {
        cout << "no" << eol;
      }
    } else if (cmd == "print") {
      inorder(root);
      preorder(root);
    }
  }

  return 0;
}

Measured memory_bytes: 19972
$N=<>;
for$i(1..$N){${-$_}+=grep$i%$'**$_<1,//..6for grep{(1x$_)!~/^(11+)\1+$/}2..$N}
for$a(-$N..0){
	$z+=$a-$_&&($$a>3&&$$_>13)+($$a>1&&$$_>23)+($$a>1&&$$_>3&&grep$a-$_&&$$_>3,$_+1..0)for-$N..0
}
print$z+($N>77)


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int cou[30];

int main(){

	string str;cin >> str;
	ll ans = 0;

	REP(i,str.size()){
		ans += i - cou[str[i] - 'a'];
		cou[str[i] - 'a']++;
	}

	cout << ans+1 << endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int main(){
     long int n,a,b,i;
    scanf("%ld",&n);
    
    for(i=1;i*i<=n;i++){
        if(n%i==0){
            a=i;
            b=n/a;
        }
    }
        printf("%ld",a+b-2);
    return 0;
}


Measured memory_bytes: 128
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var s = ReadLine().ToCharArray();

    var ans = "Good";
    for(var i = 0; i < s.Length - 1; i++)
    {
      if(s[i] == s[i+1])
      {
        ans = "Bad";
        break;
      }
    }

    WriteLine(ans);
  }
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

// constexpr int INF = 1e9;
constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

class xorShift{
    uint32_t x, y, z, w;
    static const double TO_DOUBLE;
public:
    xorShift(){
        x = 123456789;
        y = 362436069;
        z = 521288629;
        w = 88675123; 
    }
    xorShift(uint32_t seed){
        x = seed = 1812433253u * (seed ^ (seed >> 30));
        y = seed = 1812433253u * (seed ^ (seed >> 30)) + 1;
        z = seed = 1812433253u * (seed ^ (seed >> 30)) + 2;
        w = seed = 1812433253u * (seed ^ (seed >> 30)) + 3;
    }
    uint32_t nextInt(uint32_t n){
        uint32_t t = x ^ (x << 11);
        x = y; y = z; z = w;
        w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
        return w % n;
    }
    uint32_t nextInt(){
        uint32_t t = x ^ (x << 11);
        x = y; y = z; z = w;
        return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    }
    double nextDouble(){
        return nextInt() * TO_DOUBLE;
    }
};
const double xorShift::TO_DOUBLE = 1.0 / (1LL << 32);

class Timer{
    chrono::time_point<chrono::system_clock>start;
public:
    Timer(){
        start = chrono::system_clock::now();
    }
    double duration(){
        return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()- start).count();
        //return chrono::duration<chrono::milliseconds>(chrono::system_clock::now()- start).count();
    }
};

Timer T;
xorShift rnd;
constexpr double TIME_LIMIT = 1900;

int D = 365;
vector<int> c(26);
vector<vector<int>> s(D, vector<int>(26));

int main(){
  cin >> D;
  REP(i, 26){
      cin >> c[i];
  }
  REP(i, D){
      REP(j, 26){
          cin >> s[i][j];
      }
  }
  REP(i, D){
      cout << (i%26)+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3680
#include<stdio.h>
int main(){
  int i,j,b,c;
  char s[1010],k[]={"qwertasdfgzxcvbyuiophjklnm"};
  while(scanf("%s",s),s[0]-'#'){
    b=2;
    for(i=c=0;s[i];i++){
      for(j=0;s[i]-k[j];j++);
      if(b-j/15)c++;
      b=j/15;
    }
    printf("%d\n",c-1);
  }
  return 0;
}

Measured memory_bytes: 540
#include<stdio.h>
#define MAX 100


void insertionSort(int A[],int n){
 int i,j;
 int x;
 
 for(i=0;i<n;i++){

   x=A[i];
   j=i-1;
   while(j>=0 && x<A[j]){
      A[j+1]=A[j];
      j--;
   }
   A[j+1]=x;
   for(j=0;j<n-1;j++)printf("%d ",A[j]);
   printf("%d\n",A[n-1]);

 }


return;
}

int main(){
 int n,i;
 int A[MAX];

 scanf("%d",&n);
 for(i=0;i<n;i++)scanf("%d",&A[i]);

 insertionSort(A,n);

return 0;
}


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

int main(){
    int n,t; cin >> n >> t;
//    cout << n << " " << t << endl;
    int min_c = 2000;
    for(int i = 0 ; i < n ; i++){
        int c,tt; cin >> c >> tt;
//        cout << c << " " << tt << endl;
        if(tt <= t && min_c > c){
            min_c = c;
        }
    }

    if(min_c ==  2000){
        cout << "TLE" << endl;
    }else{
        cout << min_c << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import math
N, M = map(int, input().split())
mod = 10**9+7

if abs(N - M) <= 1 and N == M:
    print(2*math.factorial(N)*math.factorial(M)%mod)

elif abs(N - M) <= 1 and N != M:
    print(math.factorial(N)*math.factorial(M)%mod)

else:
    print(0)

Measured memory_bytes: 5236
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int n, a, b;
    cin >> n >> a >> b;
    if (n*a<=b) cout << n*a << endl;
    else cout << b << endl;
    return 0;
}


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


int main()
{
	unsigned long long int x;
	unsigned long long int y;
	cin >> x>> y;

	if (x%y == 0) {
		cout << -1 << endl;
	}
	else {
		cout << x * y + x << endl;
	}

    return 0;
}



Measured memory_bytes: 256
class Dice
    @faces = nil

    def initialize arr
        @faces = arr
    end

    def top
        @faces[0]
    end

    def rotate news
        f = @faces.dup
        case news
        when "N"
            @faces = [f[1], f[5], f[2], f[3], f[0], f[4]]
        when "E"
            @faces = [f[3], f[1], f[0], f[5], f[4], f[2]]
        when "W"
            @faces = [f[2], f[1], f[5], f[0], f[4], f[3]]
        when "S"
            @faces = [f[4], f[0], f[2], f[3], f[5], f[1]]
        end
    end

    def right top, front
        "SWSWS".each_char{|c|
            break if @faces[0] == front
            rotate c
        }
        rotate "S"
        "WWW".each_char{|c|
            break if @faces[0] == top
            rotate c
        }
        @faces[2]
    end

    def same? faces2
        return true if @faces == faces2
        "WWWWSWWWWSWWWWSWWWWSWSWWWWSSWWW".each_char{|c|
            rotate c
            return true if @faces == faces2
        }
        return false
    end
end

lines = []
n = gets.to_i
n.times{lines << gets.chomp.split}

differ = true
for i in 0..n-2
    for j in i+1..n-1
        if Dice.new(lines[i]).same?(lines[j])
            differ = false
            break
        end
    end
end
puts differ ? "Yes" : "No"

Measured memory_bytes: 8928
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main (int argc, char *argv[]) 
{
    map<string, long long> ms;
    long long n;
    long long ans = 0;

    cin >> n;
    for (long long i = 0; i < n; i++)
    {
        string str;
        cin >> str;
        sort(str.begin(), str.end());
        if (ms.count(str) == 0)
        {
            ms.insert(make_pair(str, 1));
        }
        else
        {
            ms[str]++;
        }
    }

    for (auto m : ms)
    {
        string str = m.first;
        long long cnt = m.second;
        if (cnt > 1)
        {
            ans += ((cnt - 1) * (1 +  cnt - 1)) / 2;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Piont{
	int x,y;
}; 
double length(Piont a, Piont b){
	return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
}
int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++){
		a[i] = i;
	}
	Piont pionts[n];
	for(int i=0; i<n; i++){
		cin>>pionts[i].x;
		cin>>pionts[i].y;
	}
	double cnt = 0;
	do{
		
		for(int i=0; i<n-1; i++){
			cnt += length(pionts[a[i]], pionts[a[i+1]]);
		}
	}while(next_permutation(a, a+n));
	int v = 1;
	while(n){
		v*=n--;
	}
	printf("%lf\n", cnt/v);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<N; i++){ ;
int main() {
   int A;
   string op;
   int B;
   cin>>A>>op>>B;
   if(op=="+"){
       cout<<A+B<<endl;
   }
   else
   {
       cout<<A-B<<endl;
   }
   
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

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

const ll INF = 1e18;
const int mod = 1e9+7;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
vector<edge> graph[MAX]; // 隣接リスト
bool visited[MAX]; // 訪問の有無
int cnt = 0, ans = 0;

void dfs(int cur) {
    cnt++;
    visited[cur] = true;
    for (edge e : graph[cur]) {
        if (not visited[e.to]) {
            dfs(e.to);
        }
    }
}

int n, m; // 変数

int main() {
// input
    cin >> n;
    cin >> m;
    rep(i, m) {
        int a, b;
        cin >> a;
        cin >> b;
        graph[a].push_back({b,0});
        graph[b].push_back({a,0});
    }
// solve
    rep(i, n) {
        cnt = 0;
        if (not visited[i]) {
            dfs(i);
            // cout << cnt << "\n";
            ans = max(cnt, ans);
        }
    }
// output
    cout << ans << "\n";
}

Measured memory_bytes: 39628
eval'b=1,1,a=2,3,5,8,13,21
%d.times{a=0,*(1..w=%d).map{|i|t=0;3.times{|j|t+=a[j+=i-1]*b[[i,j].min-1]*b[w-[i,j].max]};t},0}
p a[%d].%%10**9+7'%gets.split

Measured memory_bytes: 3964
import numpy as np

N = int(input())
a_s = input().split()
for i in range(N):
    a_s[i] = int(a_s[i])
a_s = np.array(a_s)
    
#sum = 1,-1,1, ...
ans1 = 0
sum0 = 0
for i ,a in enumerate(a_s):
    sum1 = sum0 + a
    if i==0:
        if sum1>0:
            pass
        else:
            ans1 += abs(1 - sum1)
            sum1 = 1
            
    elif i%2==0:
        if sum1*sum0<0:
            pass
        else:
            ans1 += abs(1 - sum1)
            sum1 = 1
            
    else:
        if sum1*sum0<0:
            pass
        else:
            ans1 += abs(-1 - sum1)
            sum1 = -1
    sum0 = sum1
    
#sum = -1,1,-1, ...
ans2 = 0
sum0 = 0
for i ,a in enumerate(a_s):
    sum2 = sum0 + a
    if i==0:
        if sum2<0:
            pass
        else:
            ans2 += abs(-1 - sum2)
            sum2 = -1
            
    elif i%2==0:
        if sum2*sum0<0:
            pass
        else:
            ans2 += abs(-1 - sum2)
            sum2 = -1
            
    else:
        if sum2*sum0<0:
            pass
        else:
            ans2 += abs(1 - sum2)
            sum2 = 1
    sum0 = sum2
    
ans = min(ans1,ans2)
print(ans)

Measured memory_bytes: 22240
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

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

	int x; cin >> x;
	int i(1);
	while (i*(i + 1) / 2 < x)i++;
	cout << i << endl;
	

	return 0;
}

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

int main(){
    int r;
    cin >> r;
    if(r<1200) cout << "ABC" << endl;
    else if(r<2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

f = False
n = 0

for i in range(N):
    if A[i] == 0:
        f = True
    elif A[i] < 0:
        n += 1
        A[i] = abs(A[i])

ans = 0
for i in A:
    ans += i

if f:
    print(ans)
elif n % 2 == 0:
    print(ans)
elif n % 2 == 1:
    print(ans - 2 * min(A))


Measured memory_bytes: 14412
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
    def print_top(self): print(self.top)
 
label = list(map(int,input().split()))
op_list = list(input())
d = dice(label)
for op in op_list:
    d.roll(op)
d.print_top()

Measured memory_bytes: 7768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define rrep(i,n) for (int i = (n - 1);i >= 0;i--)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

    int n,r;
    cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
}

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

const int MAXN = 1<<18|1;

int n, x;

struct dat {
	int mx, sec;
	friend dat operator + (const dat &a, const dat &b)
	{
		if (a.mx >= b.mx) return (dat) {a.mx, max(b.mx, a.sec)};
		else return (dat) {b.mx, max(a.mx, b.sec)};
	}
} a[MAXN];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < 1<<n; i++) {
		scanf("%d", &x);
		a[i] = (dat) {x, -1000000000};
	}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 1<<n; j++)
			if (j>>i&1)
				a[j] = a[j]+a[j^(1<<i)];
	//for (int i = 1; i < 1<<n; i++)
	//	a[i] = a[i]+a[i-1];
	int pre = 0;
	for (int i = 1; i < 1<<n; i++) {
		pre = max(pre, a[i].mx+a[i].sec);
		cout << pre << endl;
	}
	return 0;
}


Measured memory_bytes: 5120
#include <iostream>

using namespace std;

int main(){
  int i;
  int money = 100000;

  cin >> i;

  int cutoff = 1000;

  double dif;
  for(; i > 0; i--){
    money += money*0.05;
    dif = ((int)money/cutoff)*cutoff;
    if(money - dif > 0){
      money = dif + cutoff;
    }
  }

  cout << money << endl;
}

Measured memory_bytes: 3068