akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

vi tate, yoko;
vi ans;
vi x,y,p;
int n;

void dfs(int i, int cnt){
    //ここで計算する
    if(i == n){
        int cnt = tate.size() + yoko.size() - 2;
        int sum = 0;
        rep(i,n){
            int d = LINF;
            rep(j,tate.size())d = min(d, abs(tate[j]-x[i]));
            rep(j,yoko.size())d = min(d, abs(yoko[j]-y[i]));
            sum += p[i] * d;
        }
        ans[cnt] = min(ans[cnt], sum);
        return;
    }

    dfs(i+1,cnt);

    tate.push_back(x[i]);
    dfs(i+1,cnt+1);
    tate.pop_back();

    yoko.push_back(y[i]);
    dfs(i+1,cnt+1);
    yoko.pop_back();
}

signed main(void) {
    cin >> n;
    x = y = p = vi(n);
    rep(i,n)cin >> x[i] >> y[i] >> p[i];
    ans = vi(n+1,LINF);
    int ma = 1;
    rep(i,n)ma *= 3;
    tate.push_back(0);
    yoko.push_back(0);
    dfs(0,0);
    rep(i,n+1)cout << ans[i] << endl;
}


Measured memory_bytes: 3612
from sys import stdin,stdout
N,W=map(int,stdin.readline().split())
matrix=[[-1 for i in range(0,W+1)]for j in range(0,N+1)]
for i in range(0,len(matrix)):
    matrix[i][0]=0
for i in range(0,len(matrix[0])):
    matrix[0][i]=0
weights=[]
values=[]
for i in range(0,N):
    w,v=map(int,stdin.readline().split())
    weights.append(w)
    values.append(v)
for item in range(1,N+1):
    for weight in range(1,W+1):
        if(weights[item-1]<=weight):
            matrix[item][weight]=max(values[item-1]+matrix[item-1][weight-weights[item-1]],matrix[item-1][weight])
        else:
            matrix[item][weight]=matrix[item-1][weight]
print(matrix[N][W])


Measured memory_bytes: 171656
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <functional>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	scanf("%d", &n);
	vector<ll> v(n + 1);
	for (int i = 0; i < n; ++i) {
		scanf("%lld", &v[i + 1]);
		v[i + 1] += v[i];
	}
	vector<vector<ll> > dp(n, vector<ll>(n));
	for (int i = n - 1; i >= 0; --i)
		for (int j = i; j < n; ++j) {
			if (i == j)
				dp[i][j] = 0;
			else {
				dp[i][j] = 1e18;
				for (int k = i; k < j; ++k)
					dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + v[j + 1] - v[i]);
			}
		}
	printf("%lld\n", dp[0][n - 1]);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec a(n);
    rep(i,n)cin>>a[i];
    Vec x = a;
    sort(rALL(x));
    ll m = x[(n-1)/2];
    ll m1 = x[(n+1)/2];
    rep(i,n){
        if(a[i]>=m){
            cout<<m1<<endl;
        }else{
            cout<<m<<endl;
        }
    }
    return  0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

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

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

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

    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll cnt = 0;
    ll tmp = a[0];
    while(tmp%2==0) { ++cnt; tmp/=2; }
    rep(i, n) {
        tmp = a[i];
        ll check = 0;
        while(tmp%2==0) { check++; tmp/=2; }
        if (cnt!=check) { cout << 0 << endl; return 0; }
    }
    ll l = 1;
    rep(i, n) {
        l = lcm(l, a[i]/2);
        if (l>m) { cout << 0 << endl; return 0; }
    }

    cout << m/l - (m/(2*l)) << endl;

    return 0;
}


Measured memory_bytes: 1024
n, T = map(int, input().split())
c = []
t = []
cost = []
for i in range(n):
    _c, _t = map(int, input().split())
    c.append(_c)
    t.append(_t)
    if T >= t[i]:
        cost.append(c[i])

if not(cost):
    print("TLE")
else:
    print(min(cost))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    int ans = 0;
    if(n >= 2){
        ans += n*(n-1)/2;
    }
    if(m >= 2){
        ans += m*(m-1)/2;
    }
    cout << ans <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a, b, ans;
    char op;
    while(!(op == '?'))
    {
        scanf("%d %c %d", &a, &op, &b);
        if (op == '+')
        {
            printf("%d\n", a + b);
        }
        if (op == '-')
        {
            printf("%d\n", a - b);
        }
        if (op == '*')
        {
            printf("%d\n", a * b);
        }
        if (op == '/')
        {
            printf("%d\n", a / b);
        }
    }
    return 0;
}


Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  int n,f=0;
  cin>>n;
  while(n--)
  {
    int a;
    cin>>a;
    if(a%2==0){
    if(a%3==0||a%5==0)
    {}
    else
      f=1;}
  }
  if(f)
    cout<<"DENIED";
  else
    cout<<"APPROVED";
}

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
N
K
X
Y

x*min(k,n)+y+max(0,n-k)
 */

int n,k,x,y;

int main(){
  cin >> n >> k >> x >> y;
  cout << x*min(k,n)+y*max(0,n-k) << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;


int main(){
    ll A,B,N;
    cin>>A>>B>>N;
    
    ll ans=0;
    if(B==1){
       ans=0;
    }else if(N<B){
        ll a=floor(A*N/B);
        ll b=floor(N/B);
        ans=a-A*b;
    }else{
        ll a=floor(A*(B-1)/B);
        ll b=floor((B-1)/B);
        ans=a-A*b;
    }
    
      cout<<ans<<endl;
    /*
    ll ans2=0;
    
    
    for(int x=1;!(x%B==0)&&(x<=N);++x){
        ll a=(A*(x))/B;
        ll b=(x)/B;
        ll c=a-A*b;
        //cout<<"x:"<<x<<" a:"<<a<<" "<<"-A*x/B:"<<A*b<<" ans:"<<ans<<endl;
        ans2=ans2>=c?ans2:c;
    }

    cout<<"ans2: "<<ans2<<endl;
     */
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
string s;
string dp[55][55];
string mymax(string a,string b)
{
	if(a.size()==0||b.size()==0)return a.size()==0?b:a;
	if(a.size()<b.size())return b;
	else if(a.size()>b.size())return a;
	else return a<b?b:a;
}
main()
{
	cin>>s;
	int N=s.size();
	for(int i=0;i<N;i++)
	{
		if(s[i]=='?')
		{
			dp[i][i+1]="9";
		}
		else if(s[i]>='0'&&s[i]<='9')dp[i][i+1]=s.substr(i,1);
		else dp[i][i+1]="";
	}
	for(int k=2;k<=N;k++)for(int i=0;i+k<=N;i++)
	{
		dp[i][i+k]="";
		bool flag=s[i]!='0';
		for(int j=0;j<k;j++)flag&=s[i+j]>='0'&&s[i+j]<='9'||s[i+j]=='?';
		if(flag)
		{
			for(int j=0;j<k;j++)dp[i][i+k]+=s[i+j]=='?'?'9':s[i+j];
			continue;
		}
		if(k<6)continue;
		if(!((s[i+1]=='('||s[i+1]=='?')&&(s[i+k-1]==')'||s[i+k-1]=='?')))continue;
		if(s[i]=='L'||s[i]=='?')
		{
			for(int l=3;l<k-2;l++)
			{
				if(s[i+l]!=','&&s[i+l]!='?')continue;
				if(dp[i+2][i+l]!=""&&dp[i+l+1][i+k-1]!="")dp[i][i+k]=mymax(dp[i][i+k],dp[i+2][i+l]);
			}
		}
		if(s[i]=='R'||s[i]=='?')
		{
			for(int l=3;l<k-2;l++)
			{
				if(s[i+l]!=','&&s[i+l]!='?')continue;
				if(dp[i+2][i+l]!=""&&dp[i+l+1][i+k-1]!="")dp[i][i+k]=mymax(dp[i][i+k],dp[i+l+1][i+k-1]);
			}
		}
	}
	cout<<(dp[0][N]!=""?dp[0][N]:"invalid")<<endl;
}



Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(n%2){
        cout<<"No"<<endl;
    }else{
        if(s.substr(0,n/2)==s.substr(n/2,n/2)) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

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

int h[1005];

int main() {
  int n; cin >> n;
  for (int i = 1; i <= n; i++) cin >> h[i];
  int ans = 1;
  for (int i = 2; i <= n; i++) {
    bool ok = true;
    for (int j = 1; j < i; j++)
      ok = ok && h[j] <= h[i];
    ans += ok ? 1 : 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1005
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int n,a[N][N],c;
int mark[N];
int q[2][N],h[2],t[2];
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++)for(int j=1; j<n; j++)scanf("%d",&a[i][j]);
	for(int i=1; i<=n; i++)a[i][0]=1,q[0][t[0]++]=i;
	for(int i=1; ; i++) {
		c^=1,h[c]=t[c]=0;
		int f=1;
		while(h[c^1]<t[c^1]) {
			int j=q[c^1][h[c^1]++];
			if(mark[j]==i)continue;
			if(a[j][0]!=n)f=0;
			int to=a[j][a[j][0]];
			if(a[to][a[to][0]]==j) {
				mark[j]=mark[to]=i;
				q[c][t[c]++]=to,q[c][t[c]++]=j;
			}
		}
		if(f)return !printf("%d\n",i-1);
		if(t[c]==0)return !puts("-1");
		for(int i=h[c];i<t[c];i++)a[q[c][i]][0]++;
	}
	return 0;
}


Measured memory_bytes: 4224
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int c = scanner.nextInt();
    String out = "";
    for (int ii = 0; ii < c; ii++) {
      int[] a = {scanner.nextInt(), scanner.nextInt(), scanner.nextInt()};
      java.util.Arrays.sort(a);
      if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) {
        out += "YES\n";
      } else {
        out += "NO\n";
      }
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 35608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
    char s[11];
    scanf("%s",s);

    int i,j;
    // char sback[strlen(s)];
    // for(i=strlen(s)-1;i>=0;i--){
    //     j = 0;
    //     sback[j] = s[i];
    //     j++;
    // }

    long long sum=0,ans=0,isum=0;
    long long tmp;
    int count=0;
    for(i=0;i<( 1 << ( strlen(s) - 1 ) );i++){
        // tmp = atoi(sback[strlen(s)-1]);
        tmp = s[0] - '0';
        // printf("tmp0=%lld\n",tmp);
        for(j=0;j<( strlen(s) - 1 );j++){
            if( i & ( 1 << j ) ){
                ans += tmp;
                tmp = 0;
            }
            tmp = tmp*10 + (s[j+1] - '0');
        }
        count++;
        // printf("tmp=%lld,count=%d\n",tmp,count);
        ans += tmp;
    }

    printf("%lld",ans);

    return 0;
}

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

using namespace std;

const long long mod = 1e9 + 7;

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

  vector<long long> pos, neg;
  for(int i = 0; i < N; i++){
    long long A;
    cin >> A;
    if(A >= 0) pos.push_back(A);
    else neg.push_back(-A);
  }

  int n_pos = int(pos.size()), n_neg = int(neg.size());

  long long ans = 1;

  if(K == N){
    for(int i = 0; i < n_pos; i++){
      ans *= pos[i];
      ans %= mod;
    }

    for(int i = 0; i < n_neg; i++){
      ans *= -neg[i];
      ans %= mod;
    }
  }else if(n_neg == N && (K & 1)){
    sort(neg.begin(), neg.end());

    ans = -1;
    for(int i = 0; i < K; i++){
      ans *= neg[i];
      ans %= mod;
    }
  }else{
    sort(pos.begin(), pos.end(), greater<long long>());
    sort(neg.begin(), neg.end(), greater<long long>());

    int idx_pos = 0, idx_neg = 0;

    if(K & 1){
      --K;
      ans = pos[idx_pos++];
    }

    for(int i = 0; i < K; i += 2){
      if(idx_pos + 1 < n_pos && idx_neg + 1 < n_neg){
        if(pos[idx_pos] * pos[idx_pos + 1] < neg[idx_neg] * neg[idx_neg + 1]){
          ans *= neg[idx_neg] * neg[idx_neg + 1] % mod;
          idx_neg += 2;
        }else{
          ans *= pos[idx_pos] * pos[idx_pos + 1] % mod;
          idx_pos += 2;
        }
      }else if(idx_pos + 1 < n_pos){
        ans *= pos[idx_pos] * pos[idx_pos + 1] % mod;
        idx_pos += 2;
      }else{
        ans *= neg[idx_neg] * neg[idx_neg + 1] % mod;
        idx_neg += 2;
      }

      ans %= mod;
    }
  }

  cout << (ans + mod) % mod << endl;

  return 0;
}


Measured memory_bytes: 5436
#include <bits/stdc++.h>
#define rep(i, x, y) for (long long i = x; i <= y; i++)
#define x first
#define y second
using namespace std;

const int N = 3e5 + 10;
typedef pair<int, int> pii;
int w, h, n, ans;
int tag[N << 2], mx[N << 2];
pii p[N], a[N], b[N];

void psd(int x) {
    if (tag[x]) {
        tag[x << 1] += tag[x];
        tag[x << 1 | 1] += tag[x];
        mx[x << 1] += tag[x];
        mx[x << 1 | 1] += tag[x];
        tag[x] = 0;
    }
}

void update(int x, int l, int r, int lx, int rx, int val) {
    if (rx < l || r < lx) return;
    if (lx <= l && r <= rx) {
        tag[x] += val, mx[x] += val; return;
    }
    psd(x);
    int mid = (l + r) >> 1;
    update(x << 1, l, mid, lx, rx, val);
    update(x << 1 | 1, mid + 1, r, lx, rx, val);
    mx[x] = max(mx[x << 1], mx[x << 1 | 1]);
}

void solve() {
    memset(mx, 0, sizeof(mx));
    memset(tag, 0, sizeof(tag));

    sort(p + 1, p + n + 1);

    int l = 0, r = 0;
    rep(i, 1, n - 1) {
        if (p[i].y <= h / 2) {
            int nxt = i - 1;
            while (l && p[i].y > a[l].y) {
                update(1, 1, n, a[l].x, nxt, a[l].y - p[i].y);
                nxt = a[l].x - 1;
                --l;
            }
            if (nxt != i - 1) a[++l] = make_pair(nxt + 1, p[i].y);
        } else {
            int nxt = i - 1;
            while (r && p[i].y < b[r].y) {
                update(1, 1, n, b[r].x, nxt, p[i].y - b[r].y);
                nxt = b[r].x - 1;
                --r;
            }
            if (nxt != i - 1) b[++r] = make_pair(nxt + 1, p[i].y);
        }
        a[++l] = make_pair(i, 0);
        b[++r] = make_pair(i, h);
        update(1, 1, n, i, i, h - p[i].x);
        ans = max(ans, p[i + 1].x + mx[1]);
    }
}

int main() {
    cin >> w >> h >> n;
    rep(i, 1, n) scanf("%d%d", &p[i].x, &p[i].y);
    p[++n] = make_pair(0, 0);
    p[++n] = make_pair(w, h);

    solve();

    rep(i, 1, n) swap(p[i].x, p[i].y);
    swap(w, h);
    solve();

    printf("%d\n", ans << 1);
    return 0;
}


Measured memory_bytes: 16768
n=input()
wa=0
#print(n[2:len(n)-1])
#print(n[len(n)])
if n[0]=="A" and n[2:len(n)-1].count("C")==1 and n[1]!="C" and n[len(n)-1]!="C":
    wa+=0
    import re
    a=re.sub('[AC ]', '',n)
else:
    wa+=1
    a=n
for i in range(len(a)):
    if 0<= ord(a[i]) - ord('a') <= 26:
        wa+=0
    else:
        wa+=1
if wa==0:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

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


int main() {
  string s; cin>>s;
  int n = s.size();
  if (n == 1) {
    print(0);
    return 0;
  }
  int ans = 0;
  int l = 0, r = n-1;
  while (l < r) {
    if (s[l] == 'x' and s[r] != 'x') {
      ++ans;
      ++l;
    } else if (s[l] != 'x' and s[r] == 'x') {
      ++ans;
      --r;
    } else if (s[l] == s[r]) {
      ++l;
      --r;
    } else {
      print(-1);
      return 0;
    }
  }
  print(ans);

  return 0;
}

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

int main(void){
int K,S;
cin >> K >> S;
int ans = 0;
for(int x = 0; x <= K; ++x){
for(int y = 0; y <= K; ++y){
int z = S - x - y;
if(0 <= z and z <= K){
 ans = ans + 1;
}
 }
 }

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

Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector
#define F first
#define S second

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {cin>>x;}
void read(double& d) {string t;read(t);	d=stod(t);}
void read(long double& d) {	string t;read(t);d=stold(t);}
template<class H, class... T> void read(H& h, T&... t) {read(h);read(t...);}
template<class A> void read(vt<A>& x) {	foe(a, x)read(a);}

// no change 
const ll MOD = 1e9+7;  
int n;
void Titan(){
	read(n);
	string s;
	read(s);
	bool valid = 1;
	if(n&1^1){
		fo(n/2){
			if(s[i]^s[n/2+i])valid =0;
		}
	}else{
		valid = 0;
	}
	cout << (valid ? "Yes" : "No" );



}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T){
		//cout << "Case #" << i+1 << ": " ;
		Titan();
	}
}
/*///////////////////////////////////////////////////////////
Important Notes : 
* check long long 
* check base cases
* do not loose Hope
* if case fails on 2nd test case maybe some cases are missing check them
* do not sit idle
* try to do it using pen/paper.
*/


Measured memory_bytes: 3540
#include <iostream>
#define REP(i, a, n) for(int i = a; i < n; i++)
using namespace std;


string X, Y;
int dp[4001][4001], m;

int main(void) {
  while(1) {
    cin >> X >> Y;
    if(cin.eof()) break;

    m = 0;

    REP(i, 0, X.length()) dp[i][0] = 0;
    REP(j, 0, Y.length()) dp[0][j] = 0;

    REP(i, 1, X.length() + 1) {
      REP(j, 1, Y.length() + 1) {
        dp[i][j] = X[i - 1] == Y[j - 1] ? dp[i - 1][j - 1] + 1 : 0;
        m = max(m, dp[i][j]);
      }
    }

    cout << m << endl;
  }

  return 0;
}

Measured memory_bytes: 63740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();

            var n = nm[0];
            var m = nm[1];

            Console.WriteLine((n * (n - 1) + m * (m - 1)) / 2);
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,a;
  cin>>h>>a;
  if(h%a==0)
  {
    cout<<h/a;
    return 0;
  }
  else
  {
    cout<<h/a + 1;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    high = 0
    ans = 0
    for a in A:
        if high > a:
            ans += high - a
        elif high < a:
            high = a
    print(ans)

if __name__=='__main__':
    main()

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

typedef long long ll;

int main(){
  vector<int> a(5);
  for (int i = 0; i < 5; i++) {
    cin >> a.at(i);
  }
  int k;
  cin >> k;

  sort(a.begin(), a.end());
  if((a.at(4)-a.at(0))>k) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
counter = {i:[] for i in range(1,n+1)}
for i in range(n):
  counter[a[i]].append(i)


ans = 0
tmp = -1
for i in range(1,n+1):
  if counter[i] == []:
    break
  for c in counter[i]:
    if tmp < c:
      tmp = c
      ans += 1
      break
  else:
    break

print(n-ans if tmp != -1 else -1)

Measured memory_bytes: 57936
#include <bits/stdc++.h>
#define BPhuong "main"
#define maxn 3006
#define maxm
#define fi(i,a,b) for(int i = a; i<= b; i++)
#define fid(i,a,b) for(int i = a; i>= b; i--)
#define se second
#define f first
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define bit(x, i) ((x>>i)&1)
#define oo 1e9
struct data{
    int x, y, z;
};
using namespace std;
int n, a[maxn], cl[maxn][maxn];
long long t[maxn][maxn], s[maxn];
ll tinh(int d, int c)
{
    if(d == c)
    {
        return a[d];
    }
    if(cl[d][c]) return t[d][c];
    cl[d][c] = 1;
    t[d][c] = s[c]-s[d-1]- min(tinh(d+1, c), tinh(d, c-1));
    return t[d][c];
}
void nhap(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);cout.tie(NULL);
    //freopen(BPhuong".inp","r",stdin);
    //freopen(BPhuong".out","w",stdout);
    cin >> n;
    fi(i, 1, n) cin >> a[i];
    fi(i, 1, n) s[i] = s[i-1]+a[i];
}

void xuli(){
    long long s1 = tinh(1, n);
    ll s2 = s[n]-s1;
    cout << s1-s2;
}

int main(){
    nhap();
    xuli();
}


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

#define ios                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define fr freopen("in.txt", "r", stdin)
#define ll long long
#define F first
#define S second
#define mem(v, x) memset(v, x, sizeof(v))
#define EB emplace_back
#define PB push_back
#define MP make_pair

int main()
{
    // fr;
    ios;

    ll n, a, b;
    cin >> n >> a >> b;
    ll sum = a + b;
    ll res = a * (n / sum) + min(a, n % sum);
    cout << res << "\n";
}

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

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


int main() {
    ll k;
    cin >> k;

    int n = 50;

    cout << n << endl;
    for (int i = 0; i < 50; i++) {
        cout << ((n + 1) * ((k + n - 1 - i) / n) - k + 49) << ' ';
    }
    cout << endl;
}

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

int a[20];
int x[20][20];
int y[20][20];

int main(){
  int n;
  cin >> n;
  rep(i,n){
   cin >> a[i];
    rep(j,a[i]){
    	cin >> x[i][j] >> y[i][j];
    }
  }

  int ans = 0;

  for(int bit = 0; bit < (1 << n); ++bit){
  	bitset<15> s(bit); 
  	bool can = true;
  	int cont = 0;

  	rep(i,n){
  		if(bit & (1 << i)){
  			++cont;
  			rep(j,a[i]){
  				if(y[i][j] ^ s.test(x[i][j]-1)){
  					can = false;
  				}
  			}
  		}else continue;
  	}
  	if(can) ans = max(ans, cont);
  }
  cout << ans << endl;
  return 0;
}


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

/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let n: i32 = read();
    println!("{}",n*800-(n/15)*200);
}


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

#define SIZE 1001

int main() {
    vector<long long> fibonaccis(SIZE + 1);
    fibonaccis[0] = 1;
    fibonaccis[1] = 2;
    for (int i = 2; i <= SIZE; i++) {
        fibonaccis[i] = (fibonaccis[i - 1] + fibonaccis[i - 2]) % SIZE;
    }
    int v, d;
    while (cin >> v >> d) {
        vector<int> nums(fibonaccis.begin() + 1, fibonaccis.begin() + v + 1);
        sort(nums.begin(), nums.end());
        int result = 1;
        for (int i = 1, size = nums.size(); i < size; i++) {
            if (nums[i] - nums[i - 1] >= d) {
                result++;
            }
        }
        cout << result << endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int n, i, j;
   
    int a[101];

    int s = 1;

    long long c[202] = {0};

    long long min = 10000000;
   
      
    scanf("%d", &n);

    for( i = 0 ; i < n ; i = i + 1 ){

         scanf("%d", &a[i] );

         }
   
    
    for( i = 1 ; i < n ; i = i + 1 ){

         if( a[0] != a[i] ){

             s = 0;

             break;

             }

         }

    
    if( s == 1 ){

        printf("0\n");

        return 0;

        }
     

    for( i = -100 ; i < 101 ; i = i + 1 ){

         for( j = 0 ; j < n ; j = j + 1 ){

              c[100+i] += ( a[j] - i ) * ( a[j] - i );

              }

         if( min > c[100+i] ) min = c[100+i];

         }
   

    printf("%lld\n", min);


    return 0;
                                                          
}

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

static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }
}

class Program {
   public static void Main(string[] args) {
      var n = ReadLine().ToInt();
      var arr = ReadLine().Split(' ').Select(x => x.ToInt()).ToArray();

      int min = arr[0];
      for (int i = 0; i < n - 1; i++) {
         var lar = arr[i + 1];
         var sma = arr[i];

         while(true) {
            var mod = lar % sma;
               
            if (mod == 0) break;
            
            lar = sma;
            sma = mod;
         }
         
         if (sma < min) min = sma;
      }

      WriteLine(min);
   }
}


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

int main(){
	char A, B;
	cin >> A >> B;
	if (A == 'H'){
		cout << B << endl;
	}
	else {
		if (B == 'H') {
			cout << 'D' << endl;
		}
		else {
			cout << 'H' << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
LL mod = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> a(N+1), b(N+1);
    for(int i = 1;i <= N;i++){
        a[i] = 0;
        cin >> b[i];
    }
    int count = 0;
    int r = 0;
    if(N&1) r = 0;
    else    r = 1;
    for(int i = 1;i <= N;i++){
        a[b[i]]++;
        if(b[i]%2 != r || a[b[i]] == 3 || a[0] == 2){
            cout << 0 << endl;
            return 0;
        }
        if(a[b[i]] == 2)    count++;
    }
    if(count == N/2){
        LL ans = 1;
        for(int i = 1;i <= N/2;i++){
            ans *= 2;
            ans %= mod;
        }
        cout << ans << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A ( 2 * M );
  for ( int j = 0 ; j < 2 * M ; j++ ) {
    cin >> A.at(j);
  }
  for ( int i = 1 ; i < N + 1 ; i++ ) {
    int B = 0;
    for ( int j = 0 ; j < 2 * M ; j++ ) {
      if ( A.at(j) == i ) {
        B++;
      }
    }
    cout << B << endl;
  }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
k=[]
s=[]
for _ in range(m):
  tmp=list(map(lambda x: int(x)-1,input().split()))
  k.append(tmp[0]+1)
  s.append(tmp[1:])
p=list(map(int,input().split()))

count=0
for i in range(2**n):
  on=[]
  lamp=[False]*m
  for j in range(n):
    if ((i >> j) & 1):
      on.append(j)
  
  for la in range(m):
    judge=0
    for x in on:
      for y in s[la]:
        if x==y:
          judge+=1
    if judge%2==p[la]:
      lamp[la]=True
  if all(lamp):
    count+=1

print(count)



Measured memory_bytes: 44908
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
    string s,s1;
    while(cin>>s>>s1)
    {
         long l,w,t=0;
         l=s.size();
         w=s1.size();
         if(l>w)
         {
             cout<<"GREATER\n";
         }
         else if(w>l)
         {
             cout<<"LESS\n";
         }
         else
         {
             fr(i,l)
             {
                 if(s[i]>s1[i])
                 {
                     t=1;
                      cout<<"GREATER\n";
                      break;
                 }
                 else if(s[i]<s1[i])
                 {
                     t=1;
                      cout<<"LESS\n";
                      break;
                 }
             }
             if(t==0)
             {
                 cout<<"EQUAL\n";
             }
         }

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool h[500000000];
int main(){
  int n,i,t=0,q[13];
  for(i=1;t<13;i*=5)q[t++]=i;
  cin>>n;
  while(n--){
    char a[10],b[14];
    scanf("%s %s",a,b);
    for(t=i=0;i<strlen(b);i++){
      if(b[i]=='A')t+=q[i]*1;
      if(b[i]=='C')t+=q[i]*2;
      if(b[i]=='G')t+=q[i]*3;
      if(b[i]=='T')t+=q[i]*4;
    }
    if(a[0]=='i')h[t]++;
    else{
      if(h[t])cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
  }
}



Measured memory_bytes: 8376
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int party[20]; // [1~n]��
    int place;
    string c;
    cin>>n;
    while(n){
        place=0;
        for(int i=0;i<=n;i++){
            party[i]=0;
        }
        cin>>c;
        int j=1;
        for(int i=0;i<100;i++){
            if(c[i] == 'M'){
                party[j]++;
            }
            if(c[i] == 'S'){
                place += party[j]+1;
                party[j] = 0;
            }
            if(c[i] == 'L'){
                party[j] += place+1;
                place = 0;
            }
            j++;
            if(j > n){
                j = 1;
            }
        }
        sort(party,party+(n+1));
        for(int i=1;i<=n;i++){
            cout<<party[i]<<" ";
        }
        cout<<place<<"\n";
        cin>>n;
    }
    return 0;
}




Measured memory_bytes: 3192
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
long long skn(long long n,long long m){
  long long mn = n * m;
  for(int i = 1; i < min(n,m)+1; i++){
    if(n%i==0 && m%i==0){
      mn = n * m / i;
    }
  }
  return mn;
}
int main(){
  int n,m;
  cin >> n >> m;
  string s,t;
  cin >> s >> t;
  bool ok = true;
  long long saisyo = skn(n,m);
  long long w_n = saisyo/n;//w_mの文字列の長さ分
  long long w_m = saisyo/m;//w_nの文字列の長さ分
  long long sa = w_n * w_m;
  for(int i = 0; i < saisyo/sa; i++){
    if(s.at(w_m*i) != t.at(w_n*i)){
      ok = false;
      break;
    }
  }
  if(ok) cout << saisyo << endl;
  else cout << "-1" << endl;
}


Measured memory_bytes: 512
from collections import deque

n, T = map(int,input().split())
p = deque(map(int, input().split()))
ans = 0
s = 0
e = 0

while len(p):
    t = p.popleft()
    if e < t:
        ans += e-s
        s = t
        e = t + T
    else:
        e = t + T
ans += e - s
print(ans)

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

typedef long long ll;

int main() {
    int N, K, A;
    cin >> N >> K;
    rep(i, N) cin >> A;
    cout << (N - 1 + K - 2) / (K - 1) << "\n";
}

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

long long int dp[4001];

int main() {
    int n;
    for (int i = 0; i <= 1000; i++) {
        for (int j = 0; j <= 1000; j++) {
            dp[i + j]++;
        }
    }
    while (cin >> n) {
        long long int ans = 0;
        for (int i = 0; i <= n; i++) {
            ans += dp[i] * dp[n - i];
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3112
#include <iostream>

using namespace std;

int main(){
  int N;
  //scanf("%d\n",&N );
  cin >> N;
  if(N%2==1){
    cout << 1.*(N+1)/(2*N);
    //printf("%f\n",(N+1)/(2*N) );
  }else{
    //printf("%f\n",0.5);
    cout << 0.5;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;

int main(){
	int n;
	string s;
	cin >> n >> s;
	vector<int> a(n);
	rep(i,n){
		if(s[i] == 'R') a[i] = 0;
		if(s[i] == 'G') a[i] = 1;
		if(s[i] == 'B') a[i] = 2;
	}
	vector<ll> cnt(3);
	rep(i,n) cnt[a[i]]++;
	ll ans = 1;
	rep(i,3) ans *= cnt[i];
	rep(j,n)rep(i,j){
		int k = j + (j-i);
		if(k < n){
			if(a[i] == a[j]) continue;
			if(a[i] == a[k]) continue;
			if(a[j] == a[k]) continue;
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

//最大公約数
int gcd(int a, int b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K;
  cin >> K;
  int ans = 0;
  FOR(a,1,K+1){
    FOR(b,1,K+1) {
      FOR(c, 1, K+1) {
        int g1 = gcd(a, b);
        int g2 = gcd(g1, c);
        ans += g2;
      }
    }
  }
  cout << ans << endl;
}


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

int main(){
    int i;
    int result=0;
    string S,T;
    cin>>S;
    T=S;
    reverse(T.begin(),T.end());

    for(i=0;i<S.size()/2;i++)if(S[i]!=T[i])result++;
    cout<<result<<endl;
}

Measured memory_bytes: 256
import math
def LCM(a, b):
    g = math.gcd(a, b)
    return a * b // g

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
a0 = A[0]
div = 1
while a0 % 2 == 0:
    div *= 2
    a0 //= 2

for i in range(1, N):
    a = A[i] % div
    b = A[i] // div
    if (b % 2 == 0) or (a != 0):
        print(0)
        exit()

for i in range(N):
    A[i] //= 2

if N > 1:
    lcm = LCM(A[0], A[1])
    for i in range(2, N):
        lcm = LCM(lcm, A[i])

if N == 1:
    lcm = A[0]

ans = M // lcm
if ans % 2 == 1:
    print(ans // 2 + 1)
else:
    print(ans // 2)


Measured memory_bytes: 20308
/*
the top of the losers
*/
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=209;
int mark[N];
bool vis[N];
vector< vector<int> > v(N);
vector< pair<int,int> > ed;
int solve(int no){

    queue<pair<int,int> > q;
    q.push(mp(no,1));
    clr(vis,0);
    clr(mark,0);
    vis[no]=1;
    int lim=0;
    while(sz(q)>0){
        int siz=sz(q);
        while(siz--){
            int cur=q.front().first;
            int lv=q.front().second;
            q.pop();
            mark[cur]=lv;
            for(int i=0;i<sz(v[cur]);i++){
                int nw=v[cur][i];
                if(vis[nw]) continue;
                vis[nw]=1;
                q.push(mp(nw,lv+1));
            }
        }
        lim++;
    }
    return lim;
}
int main(){
    GO();
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        string st;
        cin>>st;
        for(int j=0;j<n;j++){
            if(st[j]=='1')
            v[i].pb(j+1),ed.pb(mp(i,j+1));
        }
    }
   ll ans=-1;
   for(int i=1;i<=n;i++){
       int ret=solve(i);

    for(int i=0;i<sz(ed);i++){
        int n1=ed[i].first;
        int n2=ed[i].second;
        if(abs(mark[n1]-mark[n2])!=1){
            ret=-1;
        }
    }
    if(ret!=-1)
        ans=max(ans,1ll*ret);
   }
    cout<<ans<<endl;
}


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

int main() {
  string s;
  cin >> s;
  int N = s.size();
  set<char> c;
  for (auto e : s) {
    if (c.count(e)) {
      cout << "no" << endl;
      return 0;
    }
    c.insert(e);
  }
  cout << "yes" << endl;
}

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

int main(){
	int N, K;
	cin >> N >> K;
	double res = 0.0;
	for(int i = 1; i <= N; i++){
		int num = i;
		double p = 1.0;
		while(num < K){
			p *= 0.5;
			num *= 2;
		}
		res += (1.0 / (double)N) * p;
	}
	printf("%.10lf\n", res);
	return 0;
}


Measured memory_bytes: 256
//  cd Desktop/Atcoder
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rep(i,n) for(i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

int main(){
    int n;
    scanf("%d",&n);
    printf("%d",n+n*n+n*n*n);
    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n, l;
    cin >> n >> l;
    int m = INT_MAX, sum = 0;
    for(int i = 0; i < n; ++i){
        int tmp;
        tmp = l + i;
        sum += tmp;
        m = min(abs(m), abs(tmp));
        if(tmp < 0) m = -1 * m;
    }
    cout << sum - m << endl;
    return 0;
}


Measured memory_bytes: 256
// Bismillahir Rahmanir Rahim .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e5+5;
vector<ll>v;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    ll num =7;
    ll coun =1;
    if(n%5==0|| n%2==0)
    {
        cout<<-1<<endl;
        return 0;
    }
    num%=n;
   while(num!=0)
   {
       num = ((num)*10+7)%n;
       coun++;
   }
   cout<<coun<<endl;
    return 0;
}



Measured memory_bytes: 3624