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

using namespace std;
typedef long long ll;

main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int i = 0;i<n;i++) cin>>h[i];
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    for(int i = 0;i<n;i++){
        for(int j = i+1;j<(i+k+1);j++){
            if(j < n)
            dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
        }
    }

    cout<<dp[n-1];
}

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

int main() {
  int H, W, N;
  cin >> H >> W >> N;
  int ans = 0;
  if (N%max(H, W)==0) ans = N/max(H, W);
  else ans = N/max(H, W)+1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
int main(){

 long long int n;
cin >> n;

long long int f = log10(n+1);

long long int t = (n+1) / pow(10,f);

cout << t - 1 + ( 9 * f );

return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
b = 1
absum = 0
m = 10 ** 9
for i in range(n):
    if a[i] < 0:
        b *= (-1)
        absum += (-a[i])
        m = min(m,-a[i])
    else:
        absum += a[i]
        m = min(m,a[i])

if b == -1:
    print(absum -  2 * m)
    #print(absum)
    #print(min(absum))
else:
    print(absum)


Measured memory_bytes: 14284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  ll n, m;
  cin >> n >> m;
  vector<vl> X(n, vl(3));
  rep(i, n) rep(j, 3) cin >> X[i][j];

  ll ans = -1LL<<40;
  rep(bit, 1<<3) {
    vl cnt(n);
    rep(i, n) {
      rep(j, 3) {
        if (bit & 1<<j)
          cnt[i] += X[i][j];
        else
          cnt[i] += -X[i][j];
      }
    }

    sort(all(cnt), greater<ll>());

    ll sum = 0;
    rep(i, m) {
      sum += cnt[i];
    }
    cmax(ans, sum);
  }

  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	int ans=0,n;
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		ans^=a[i];
	}
	for (int i=1;i<=n;i++)
	{
		cout<<(ans^a[i])<<" ";
	}
	return 0;
}

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

//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

 
 
int main(){
    string l;
    ll sf,ss;
    
    std::stack<ll>ans ;
    while(cin>>l){
        if(l=="+"){
            sf=ans.top();
            ans.pop();
            ss=ans.top();
            ans.pop();
            ans.push(sf+ss);
        }else if(l=="-"){
            sf=ans.top();
            ans.pop();
            ss=ans.top();
            ans.pop();
            ans.push(ss-sf);
        }else if(l=="*"){
            sf=ans.top();
            ans.pop();
            ss=ans.top();
            ans.pop();
            ans.push(sf*ss);
        }else{
            ans.push(stoi(l));
        }
        
    }
   
   cout<<ans.top()<<endl;
   
}
  



Measured memory_bytes: 3216
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 int k;
 cin >> k;
 int s = k / 2;
 int t = (k + 1) / 2;
 cout << s * t << endl;
}

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

using namespace std;
int a[200005];
 main()
{
        int n,ans=0,mx=0;
        cin>>n;
        for(int i=0; i<n; i++)cin>>a[i];
        a[n]=a[n-1]+1;
        for(int i=0; i<n; i++){
            if(a[i+1] <= a[i])ans++;
            else{
                mx=max(mx,ans);
                ans=0;
            }
        }
        cout<<mx<<endl;



    return 0;
}


Measured memory_bytes: 640
# 入力1行目を要素数として受け取る
N = int(input())
s = []

# 入力2行目以降をリストに要素として追加していく
for i in range(N):
    s.append(input())

#　リストから重複したものを排除し、要素を数える
print(len(set(s)))

Measured memory_bytes: 35672
#!/usr/bin/env python3


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


def main():
    L, R = read_h()

    if R - L >= 2019 or R % 2019 <= L % 2019:
        print(0)
        return

    ans = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i % 2019) * (j % 2019) % 2019)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using System;
class abc162_a{
  public static void Main(){
    String str = Console.ReadLine();
    bool flag = false;
    for(int i=0; i<str.Length; i++){
      if(str[i] == '7')
        flag = true;
    }
    if(flag){
      Console.WriteLine("Yes");
    }
    else{
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 17348
N, M, C = map(int, input().split())
*B, = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    val = 0
    for j in range(M):
        val += A[i][j] * B[j]
    val += C
    if val > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  while(true) {
    int q1; cin >> q1;
    if(q1 == 0) break;
    int b, c1, c2, q2; cin >> b >> c1 >> c2 >> q2;
    int ansX = -1, ansY;
    for(int x = 1; x <= q2 && x*c1 <= b; ++x) {
      int y = (b - x * c1) / c2;
      if(x + y >= q1) {
        ansX = x;
        ansY = y;
      }
    }
    if(ansX == -1) cout << "NA" << endl;
    else cout << ansX << ' ' << ansY << endl;
  }
}

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



int main(){
	int X,Y,Z;
	cin>>X>>Y>>Z;
	int K;
	cin>>K;
	vector<long long> A(X);
	vector<long long> B(Y);
	vector<long long> C(Z);
	for(int i=0;i<X;i++){
		cin>>A[i];
	}
	for(int i=0;i<Y;i++){
		cin>>B[i];
	}
	for(int i=0;i<Z;i++){
		cin>>C[i];
	}
	
	vector<long long> ans;
	for(int i=0;i<X;i++){
		for(int j=0;j<Y;j++){
			ans.push_back(A[i]+B[j]);
		}
	}
	sort(ans.begin(),ans.end(),greater<long long>());
	vector<long long> ans2;
	int a = min(3000,(int)ans.size());
	for(int i=0;i<a;i++){
		for(int j=0;j<Z;j++){
			ans2.push_back(ans[i]+C[j]);
		}
	}
	sort(ans2.begin(),ans2.end(),greater<long long>());
	
	for(int i=0;i<K;i++){
		cout<<ans2[i]<<endl;
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 43240
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String N = in.readLine();
		String subA = N.substring(0, 3);
		String subB = N.substring(1, 4);
		boolean condA = true;
		boolean condB = true;
		for (int i = 1; i < subA.length(); ++i) {
			if (subA.charAt(i - 1) != subA.charAt(i)) {
				condA = false;
				break;
			}
		}
		for (int i = 1; i < subB.length(); ++i) {
			if (subB.charAt(i - 1) != subB.charAt(i)) {
				condB = false;
				break;
			}
		}
		if (condA || condB) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>
#define vvl vector<vector<long long>>
#define all(A) A.begin(), A.end()

int main() {
    ll N, W; cin >> N >> W;
    vl w(N), v(N);
    rep(i,N) cin >> w[i] >> v[i];

    vvl dp(N+1, vl(W+1));

    xrep(i,1,N+1){
        rep(j,W+1){
            if(j - w[i-1] >= 0){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j - w[i-1]] + v[i-1]);
            }
            else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }

    cout << dp[N][W] << endl;
}

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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> Vec;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	int r;
	cin >> r;

	co(r*r);

	return 0;
}


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

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

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

int counter(int x){
  if(x==0) return 0;
  return counter(x>>1)+(x&1);
}

signed main()
{
  int n;
  cin>>n;
  
  for(int i=1; i<=n; i++){
    cin>>a[i];
    for(int j=1; j<=a[i]; j++){
      cin>>x[i][j]>>y[i][j];
    }
  }
  int ans=0;
  // bits ビットが立っているところが人iが正しい証言をしていることを意味する
  for(int bits=0; bits<(1<<n); bits++){
    bool ok=true;
    // 最大15人の人iについてのループ
    for(int i=1; i<=n; i++){
      // ビットiが立っている時だけ処理する
      // 正しい証言をしていると仮定しているもの(=ビットが立っている)だけ確認すればよい
      // iが立っていないものは「不確か」であって、「不正確であること」では無い事に注意
      if(!(bits & (1<<(i-1)))) continue;
      // 各人iの証言についてのループ
      for(int j=1; j<=a[i]; j++){
        // 矛盾しないかを判定する
        // 0^1 (bits上は不親切と仮定したのに正直者であると証言してしまっている)
        // 1^0 (正直者と仮定したのに不親切と証言してしまっている)
        if(((bits>>x[i][j]-1)&1) ^ y[i][j]) {
          // bits上正しいと仮定した人iの証言が全て矛盾しなければここを通らず、
          // bitsの立っているビットの数が、正直者の数と同値になる
          ok = false;
          break;
        }
      }
    }
    if(ok) chmax(ans, counter(bits));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define M 1000000007
#define int long long
#define pb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define nl "\n"
#define yy "YES\n"
#define nn "NO\n"
using namespace std;
signed main()
{
    io;
    int a,b;
    cin>>a>>b;
    cout<<(a*b);
}



Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
    private static final long MOD = 1000000007;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        if (Math.abs(N - M) > 1) {
            System.out.println(0);
            return;
        }
        long ans = 1;
        int n = N;
        int m = M;
        while (N > 0 || M > 0) {
            ans = (ans * Math.max(N, M)) % MOD;
            if (N >= M) {
                N--;
            } else {
                M--;
            }
        }
        if (n == m) {
            ans = (ans * 2) % MOD;
        }
        System.out.println(ans);
    }
}


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

long long a[100][100]={{}}, b[100][100]={{}}, c[100][100]={{}};

int main(){
    int n, m, l;
    cin >> n >> m >> l;
    int i, j, k;
    for(i = 0; i < n; i++){
        for( j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(i = 0; i < m; i++){
        for( j = 0; j < l; j++){
            cin >> b[i][j];
        }
    }
    for(i = 0; i < n; i++){
        for( j = 0; j < l; j++){
            for( k = 0; k < m; k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    for(i = 0; i < n; i++){
        for( j = 0; j < l; j++){
            if(j) cout << " ";
            cout << c[i][j];
        }
        cout << endl;
    }
}



Measured memory_bytes: 3256
s = input()
ans = 'Yes'
for index, value in enumerate(s):
    if (index + 1)%2 == 0 and value not in ['L', 'U', 'D']:
        ans = 'No'
    elif (index + 1)%2 != 0 and value not in ['R', 'U', 'D']:
        ans = 'No'
        
print(ans)

Measured memory_bytes: 9024
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
map<ll,ll > ma;
vector<ll> ki;
vector<pair<ll,ll> > it;
void sieve()
{
    ma[1] = 1;
    int i;;
    for( i=3; i*i<=20000010; i=i+2)
    {
        if(ma[i]==0)
        {
            for(int j=i*i; j<=20000010; j=j+(2*i))
            {
                ma[j] = 1;
            }
        }

    }
    int c1,c2;
    c1 = 3;
    c2 = 3;
    for(i=5; i<=20000010; i=i+2)
    {
        if(ma[i]==0)
        {
            c1=c2;
            c2=i;
            if((c2-c1)==2)
            {
                it.push_back({c1,c2});
            }
        }
    }
}

int main()
{

    ll i,j,k,a,b,c,n,t,m,d,r,g,y,f;
    vector<ll> v,s,ss,vv;
    map<char,ll> ga,ha;
    string st,et,mt;
    long double aa,bb;
    cin>>aa;
    bb = acos(-1);
    cout<<setprecision(20)<<fixed<<bb*aa*2*1.0<<endl;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[2][102];

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

	string s;
  cin>>s;
  ll n=s.size();
  if(n==2)
    cout<<s<<endl;
  else{
    reverse(s.begin(),s.end());
    cout<<s<<endl;
  }
}




Measured memory_bytes: 256
N = input()
A = map(int, raw_input().split())
B = map(int, raw_input().split())
ans = 0
for i in range(N):
  x = min(A[i], B[i])
  ans += x
  A[i] -= x
  B[i] -= x
  x = min(A[i+1], B[i])
  ans += x
  A[i+1] -= x
  B[i] -= x
print ans


Measured memory_bytes: 14440
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  int n;
  cin >> n;
  ll sum = 1;
  ll a[100010];
  rep(i, n)
  {
    cin >> a[i];
    if (a[i] == 0)
    {
      cout << 0 << endl;
      return 0;
    }
  }

  rep(i, n)
  {
    if (a[i] <= ll(1e18) / sum)
    {
      sum *= a[i];
    }
    else
    {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 4380
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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


const ll INF = 1LL<<60;

//#define __DBG__


void solve(void){

  int N, K;
  cin >> N >> K;
  
  vector<ll> h(N);
  
  REP(i,N){
    cin >> h[i];
  }
  
  vector<ll> DP(N+K,INF);
  DP[0]=0;
  
  REP2(i,1,N){
    REP2(j,1,K+1){
      if(i<j){ break;}
      DP[i] = min (DP[i], DP[i-j]+abs(h[i]-h[i-j]));
    }
  }
 
  cout << DP[N-1] << endl;

  return;
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}




Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

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

namespace io{
	const int L = (1 << 20) + 1;
	
	char buf[L], *S , *T, c;
	 
	char getchar() {
		if(S == T) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}
	
	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}
	
	char B[25], *outs=B+20, *outr=B+20;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;
		
		if(!a)*--outs = '0';
		else 
			while(a)
				*--outs = (a % 10) + 48, a /= 10;
		
		if(x)
			*--outs = x;
		
		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inp_ll;

const int MAXN = 100010;
const int MAXM = 1000010;
const int INF = 1000000000;
const int MOD = 998244353;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

int F[MAXN];

int main()
{
	
	F[0] = 1;
	int n;
	cin >> n;
	for (int i = 0; i <= n; ++ i)
		if (F[i])
		{
			F[i+4] = 1;
			F[i+7] = 1;
		}
	puts(F[n] ? "Yes" : "No");
	
	return 0;
}


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  vector<vector<ll>> memo(n, vector<ll>(n));
  for (int i = 0; i < n; i++) {
    if (n % 2 == 1) memo.at(i).at(i) = a.at(i);
    else memo.at(i).at(i) = -a.at(i);
  }
  
  for (int width = 2; width <= n; width++) {
    for (int i = 0; i + width <= n; i++) {
      int l = i, r = i + width - 1;
      if ((n - width) % 2 == 1) {
        memo.at(l).at(r) = min(memo.at(l).at(r - 1) - a.at(r), memo.at(l + 1).at(r) - a.at(l));
      }
      else {
        memo.at(l).at(r) = max(memo.at(l).at(r - 1) + a.at(r), memo.at(l + 1).at(r) + a.at(l));
      }
    }
  }
  
  cout << memo.at(0).at(n - 1) << '\n';
}

Measured memory_bytes: 70784
import fractions
#import math
from functools import reduce
def lcm_base(x, y):
  return (x * y) // fractions.gcd(x, y)
  #return (x * y) // math.gcd(x, y)

a, b, c, d = map(int, input().split())
l = lcm_base(c, d)
x = b//c-(a-1)//c
y = b//d-(a-1)//d
z = b//l-(a-1)//l
print((b-a+1)-(x+y-z))
#print(x)
#print(y)
#print(z)


Measured memory_bytes: 66028
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)
#define pb push_back

using namespace std;

const int N = 40010;
const long double eps = 1e-10;
const long double oo = 1e12;

struct Line{
	int A, B, C;
}L[N];

inline bool cmpx(const Line& u, const Line &v){
	return double(u.A) / u.B > double(v.A) / v.B;
}

inline bool cmpy(const Line& u, const Line &v){
	return double(u.B) / u.A > double(v.B) / v.A;
}

long double P, val[N];

inline bool cmp(int u, int v){
	return val[u] < val[v];
}

int rk[N], n;

int c[N];

inline int lowbit(int x){
	return x & (-x);
}

inline void add(int x){
	while(x <= n){
		c[x]++;
		x += lowbit(x);
	}
}

inline int sum(int x){
	int ret = 0;
	while(x){
		ret += c[x];
		x -= lowbit(x);
	}
	return ret;
}

bool checkx(long double x){
	P = x;
	For(i, 1, n) val[i] = (L[i].C - P * L[i].A) / L[i].B, rk[i] = i, c[i] = 0;
	sort(rk + 1, rk + n + 1, cmp);
	long long ret = 0;
	Forr(i, n, 1) ret += sum(rk[i]), add(rk[i]);
	return ret * 4 <= 1LL * n * (n - 1);
}

bool checky(double x){
	P = x;
	For(i, 1, n) val[i] = (L[i].C - P * L[i].B) / L[i].A, rk[i] = i, c[i] = 0;
	sort(rk + 1, rk + n + 1, cmp);
	long long ret = 0;
	Forr(i, n, 1) ret += sum(rk[i]), add(rk[i]);
	return ret * 4 <= 1LL * n * (n - 1);
}

int main(){
	scanf("%d", &n);
	For(i, 1, n) scanf("%d%d%d", &L[i].A, &L[i].B, &L[i].C);

	sort(L + 1, L + n + 1, cmpx);	
	long double l = -oo, r = oo;
	while(r - l > eps){
		long double mid = (l + r) / 2.0;
		if(checkx(mid)) r = mid;
		else l = mid;
	}

	printf("%.10Lf ", l);


	sort(L + 1, L + n + 1, cmpy);
	l = -oo, r = oo;
	while(r - l > eps){
		long double mid = (l + r) / 2.0;
		if(checky(mid)) r = mid;
		else l = mid;
	}

	printf("%.10Lf\n", l);
	

	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = long long;

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

void solve(){
    ll a, b;
    int k;
    cin >> a >> b >> k;

    for(ll i = a; i < min(a+k, b+1); i++){
        cout << i << endl;
    }
    for(ll i = max(b-k+1, a+k); i <= b; i++){
        cout << i << endl;
    }
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int N; cin >> N;
  long L[N]; for (int i =0; i<N; i++) cin >> L[i];
  sort(L,L+N);
  
  int count =0;
  for (int i =0; i<N; i++) {
    for (int j =i+1; j<N; j++) {
      for (int k =j+1; k<N; k++) {
        if (L[i] + L[j] > L[k] && L[i] != L[j] && L[j] != L[k]) count++;
      }
    }
  } 
  cout << count << endl;
}

Measured memory_bytes: 3636
class UnionFind(n: Int) {
    private val parent = IntArray(n, {-1})
    private val rank = IntArray(n, {0})
    private val size = IntArray(n, {1})
    private var numTree = n
    
    fun find(x: Int): Int {
        if (parent[x] == -1) {
            return x
        } else {
            parent[x] = find(parent[x])
            return parent[x]
        }
    }
    
    fun isSame(x: Int, y: Int): Boolean {
        return find(x) == find(y)
    }
    
    fun getSize(): Int {
        return numTree
    }
    
    fun sizeOf(x: Int): Int {
        return size[find(x)]
    }
    
    fun rankOf(x: Int): Int {
        return rank[find(x)]
    }
    
    fun unite(x: Int, y: Int) {
        val parentX = find(x)
        val parentY = find(y)
        
        if (parentX == parentY) {
            return
        }
        
        numTree--
        
        if (rank[parentX] < rank[parentY]) {
            parent[parentX] = parentY
            size[parentY] += size[parentX]
        } else {
            parent[parentY] = parentX
            size[parentX] += size[parentY]
            if (rank[parentX] == rank[parentY]) {
                rank[parentX]++
            }
        }
    }
}

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val AArr: Array<Pair<Int, Int>> = readInputLine().split(" ").mapIndexed { i, s -> Pair(i, s.toInt()) }.sortedBy { it.second }.toTypedArray()
    val BArr: Array<Pair<Int, Int>> = readInputLine().split(" ").mapIndexed { i, s -> Pair(i, s.toInt()) }.sortedBy { it.second }.toTypedArray()

    for (i in 0 until N) {
        if (BArr[i].second < AArr[i].second) {
            println("No")
            return
        }
    }
    
    val cycle = UnionFind(N)
    
    for (i in 0 until N) {
        cycle.unite(BArr[i].first, AArr[i].first)
    }

    if (cycle.getSize() >= 2) {
        println("Yes")
        return
    }
    
    for (i in 0 until N - 1) {
        if (AArr[i + 1].second <= BArr[i].second) {
            println("Yes")
            return
        }
    }
    
    println("No")
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 130452
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int> 
#define int long long 
#define N 20005

int32_t main(){
    int n,k;
    cin>>n>>k;
    set<int> s;
    while(k--){
        int q;
        cin>>q;
        while(q--){
            int x;
            cin>>x;
            s.insert(x);
        }
        
    }
    cout<<n-s.size()<<endl;
}

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

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

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    ll ans = 1000;
    for(i = 0;i < n-1;++i){
        if(a.at(i) < a.at(i+1)){
            ll kabu = ans/a.at(i);
            ans -= kabu*a.at(i);
            ans += kabu*a.at(i+1); 
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3568
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main() {
  int N,a;
  cin >> N;
  vector<int> A(1e6+1,0),l(N);
  rep(i,N) {
    cin >> a;
    A[a]++;
    l[i]=a;
  }
  int ans=0;
  for (auto e:l){
    A[e]--;
    auto d = divisor(e);
    bool f = false;
    for (auto k:d) if (A[k]>0) {
      f = true; break;
    }
    A[e]++;
    if (f) continue;
    else ans++;

  }
  cout << ans << endl;
}

Measured memory_bytes: 7972
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e6 + 10;
char s[N];

int main() {
  int k;
  scanf("%s%d", s, &k);
  int n = strlen(s);
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'a') continue;
    int cur = 'z' - s[i] + 1;
    if (k >= cur) {
      k -= cur;
      s[i] = 'a';
    }
  }
  k %= 26;
  if (k) {
    int x = s[n - 1] - 'a';
    x = (x + k) % 26;
    s[n - 1] = (char)(x + 'a');
  }
  puts(s);
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	char c;
	cin>>c;
	cout<<(char)(c+1);
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  vector<Int> T(2), A(2), B(2);
  cin>>T>>A>>B;

  if(A[0] - B[0] > 0) swap(A, B);
  Int P = (A[0] - B[0]) * T[0];
  Int Q = (A[1] - B[1]) * T[1];
  assert(P <= 0);

  if(P + Q == 0){
    cout<<"infinity"<<endl;
    return 0;
  }

  if(P + Q < 0){
    cout<<0<<endl;
    return 0;
  }

  if(P + Q > 0){
    Int S = (-P) / (P+Q);
    Int T = (-P) % (P+Q);
    Int ans;
    if(T == 0) ans = 1 + (S-1) * 2 + 1;
    else ans = 1 + S * 2;
    cout<<ans<<endl;
  }


  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
mod=10**9+7
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
d=defaultdict(lambda:1)
for i in range(2,n+1):
    l=factorization(i)
    for li in l:
        d[li[0]]+=li[1]
ans=1
for k,v in d.items():
    ans*=v
    ans%=mod
print(ans)

Measured memory_bytes: 3444
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  var list = getCommonDivisorList(A, B);
  var oklist = [1];
  for(var i = 1; i < list.length; i++){
    var isOK = true;
    if(oklist.length != 1){
      for(var j = 1; j < oklist.length; j++){
        if(list[i] % oklist[j] == 0){
          isOK = false;
          break;
        }
      }
    }
    if(isOK){
      oklist.push(list[i]);
    }
  }
  myerr(oklist);
  myout(oklist.length);
}
function getCommonDivisorList(val1, val2){
        var list = [];
        var tmpGcd = gcd(val1,val2);
        for(var i = 1; i * i <= tmpGcd; i++){
                if(val1 % i == 0 && val2 % i == 0){
                        list.push(i);
                        if(i * i != tmpGcd){
                                list.push(tmpGcd / i);
                        }
                }
        }
        list.sort(function(a,b){ return a - b; });
        return list;
}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}
function getDivisorList(val){
  var list = [];
  for(var i = 1; i * i <= val; i++){
    if(val % i == 0){
      list.push(i);
      if(i * i != val){
        list.push(val / i);
      }
    }
  }
  list.sort(function(a,b){ return a - b; });
  return list;
}

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

using namespace std;

int main() {

	char lower[3] = {'a', 'b', 'c'};
	int n, k;
	string s;
	
	cin >> n >> k;
	cin >> s;
	
	s[k - 1] = tolower(s[k - 1]);
	
	cout << s;


}

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

// mod の処理を忘れさせてくれるライブラリ
// https://github.com/atcoder-live/library/blob/master/mint.cpp
const int mod = 1000000007;
struct mint {
  long long x;
  mint(long long x = 0):x((x % mod + mod) % mod) {}
  mint operator-() const {return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

// nCk n が大きくて k が小さい場合
mint f(int n, int a) {
  mint x = 1;
  mint y = 1;
  for (int i = 0; i < a; i++) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main() {

  int N, K;
  cin >> N >> K;

  mint answer = 0;

  for (int i = 1; i <= K; i++) {
    answer = f(N - K + 1, i) * f(K - 1, i - 1);
    cout << answer.x << endl;
  }

  return 0;
}

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

int main(){
	int a[26];
	bool flag=false;
	string s;

	cin>>s;
	for(int i=0;i<26;i++)a[i]=0;
	for(int i=0;i<s.length();i++)
		a[s[i]-'a']++;
	for(int i=0;i<s.length();i++){
		if(a[i]>1)flag=true;
	}
	if(flag)cout<<"no"<<endl;
	else cout<<"yes"<<endl;
}

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

int main() {
  int N;
  string s;
  cin >> N >> s;
  int L = 0, R = N-1;
  int ans = 0;
  while (L < R) {
    while (s[L] == 'R') L++;
    while (s[R] == 'W') R--;
    if (L >= N || R < 0 || L > R) break;
    L++; R--;
    ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3760
import * as fs from 'fs'
const reader = (s: string) => s.split('\n')

function Main(input: string) {
  const N = parseInt(reader(input)[0], 10)
  const A = reader(input)[1]
    .split(' ')
    .map(x => parseInt(x, 10))

  if (N !== 1) {
    const mul = A.reduce((acc, cur) => acc * cur)
    let num = 0

    for (let i = 0; i < N; i++) {
      const tmp = A.filter((_, ind) => i !== ind)
      num += tmp.reduce((acc, cur) => acc * cur)
    }

    console.log(mul / num)
  } else {
    console.log(A[0])
  }
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 11468
import string
import math
n = int(input())

lis = list(string.ascii_lowercase)

ans =""
i = 1
while n > 0:
    if n <= 26:
        t = n % 26
        ans += lis[t-1]
        break
    else:
        if n % 26 == 0:
            ans += lis[25]
            n = (n // 26) -1
        else:
            t = n % 26
            ans += lis[t-1]
            n = n//26
    
print(ans[::-1])

Measured memory_bytes: 9980
N=int(input())
import string
S=[]
d = dict.fromkeys(string.ascii_lowercase, 0)
for i in range(N):
  dc = d.copy()
  k = input()
  for s in k:
    dc[s] += 1
  S.append(dc)
ANS = ''

for s in string.ascii_lowercase:
  m = 50
  for i in range(N):
    m = min(m, S[i][s])
  ANS += (s * m)
    
print(ANS)
  
  

Measured memory_bytes: 3768
h, w = map(int, input().split())

s = [input() for _ in range(h)]

ans = 'Yes'

for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '#' and s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and s[i][j+1] == '.':
            ans = 'No'

print(ans)


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

int N;
char S[300][300] = {'0'};
char NewS[300][300] = {'0'};

int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> S[i][j];
        }
    }
    bool NGflag = false;
    long long int count = 0;
    for(int A=0;A<N;A++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                NewS[i][j] = S[(i+A)%N][j];
            }
        }
        for(int i=0;i<N;i++){
            for(int j=i;j<N;j++){
                if(NewS[i][j] != NewS[j][i]) NGflag =true;
            }
        }
        if(!NGflag){
            count += N;
        }
        NGflag = false;
    }
    cout << count << endl;
}


Measured memory_bytes: 384
#include <iostream>

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

    char str[21];
    std::cin >> str;

    int cnt = 0;
    while (str[++cnt]);

    while (cnt-- > 0)
        std::cout << str[cnt];
    std::cout << std::endl;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int A,B,h=100,w=100;

int main(){
	cin>>A>>B;
	A--;B--;
	cout<<h<<' '<<w<<endl;
	vvi a(h,vi(w));
	for(int i=0;i<h/2;i++) for(int j=0;j<w;j++) a[i][j]=1;
	for(int i=0;i<h&&A;i++) for(int j=0;j<w&&A;j++) if(i%2==0&&j%2==0) a[i][j]=0,A--;
	for(int i=h-1;i>=0&&B;i--) for(int j=0;j<w&&B;j++) if(i%2==0&&j%2==0) a[i][j]=1,B--;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++) cout<<(a[i][j]?'#':'.');
		cout<<endl;
	}
}

Measured memory_bytes: 256
def f(v,i):s,n=4*2**v-3,2*2**v-1;m=s/2+1;return 0 if i < 1 or i > s else [0, f(v - 1, i - 1), n / 2 + 1, f(v - 1, i - s / 2 - 1) + n / 2 + 1, n, 1][(i > 1) + (i >= m) + (i > m) + (i >= s) + (v == 0) * 3]

print f(*map(int, raw_input().split()))

Measured memory_bytes: 2692
#include<bits/stdc++.h>
#include<unordered_map>
/*
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*    ▀▀       ▀▀▀▀▀▀    ▀     ▀▀▀▀▀▀      ▀    ▀
*   ▀  ▀      ▀         ▀     ▀            ▀  ▀
*  ▀    ▀     ▀ ▀ ▀     ▀     ▀ ▀ ▀         ▀
* ▀ ▀▀▀▀ ▀    ▀         ▀     ▀             ▀
*▀        ▀   ▀         ▀     ▀             ▀
*▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
*/
using namespace std;
void afify()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define ll long long
#define ld long double
#define mk make_pair
#define loop(i,intial,n)  for(int i=int(intial);i<n;i++)
#define loopn(j,n) for(int j=int(n);j>=0;j--)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) v.begin(),v.end()
///////////////////////////////////////
#define SCD(a) scanf("%d",&a)
#define SCD2(a,b) scanf("%d %d",&a,&b)
#define SCLL(a) scanf("%lld",&a)
#define SCLL2(a,b) scanf("%lld %lld",&a,&b)
#define PRD(a) printf("%d\n",a)
#define PRLL(a) printf("%lld\n",a)
///////////////////////////////////////
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <vi> vvi;
typedef vector <vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vpii> vvpii;
typedef stringstream ss;
const ll oo = (ll) 10e9+7;
const double EPS = 1e-4;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
//ifstream ifs("input.txt");
//ofstream ofs("output.txt");

int main()
{
    afify(); 
	int n;
	cin>>n;
	vi v(n);
	int sum=0;
	loop(i,0,n){
		cin>>v[i];
		sum+=v[i];
	}
	sort(all(v));
	if(sum%10!=0){cout<<sum<<endl;return 0;}
	loop(i,0,n){
		if(v[i]%10!=0){
			sum-=v[i];
			cout<<sum<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0; 
 
} 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
using namespace std;
const int INF = 2000000005;
int pk[5005] = { 0 }, pk2[5005] = { 0 };

int main() {
	
		int n;
		cin >> n;
		int sm = 0, sm2 = 0;
		for (int i = 0; i < n; i++) {
			cin >> pk[i];
			pk2[i] = pk[i];
			sm += pk[i];
			sm2 += pk[i];
		}
		for (int i = 1; i < n - 2; i++) {
			int m = min(pk[i], pk[i + 1]);
			pk[i] -= m;
			pk[i + 1] -= m;
		}
		int m2 = min(pk[0], pk[1]);
		pk[0] = 0;
		pk[1] -= m2;
		int m3 = min(pk[n - 2], pk[n - 1]);
		pk[n - 2] -= m3;
		pk[n - 1] = 0;
		//ここまでで合計分の削除が完了
		for (int i = 0; i < n; i++) {
			/*cout << pk[i] << " ";*/
			sm += pk[i];
		}
		/*cout << endl << sm << endl;*/
		//今度は逆から
		for (int i = n - 2; i > 1; i--) {
			int m = min(pk2[i], pk2[i - 1]);
			pk2[i] -= m;
			pk2[i - 1] -= m;
		}
		int m4 = min(pk2[0], pk2[1]);
		pk2[0] = 0;
		pk2[1] -= m4;
		int m5 = min(pk2[n - 2], pk2[n - 1]);
		pk2[n - 2] -= m5;
		pk2[n - 1] = 0;
		//ここまでで合計分の削除が完了
		for (int i = 0; i < n; i++) {
			/*cout << pk2[i] << " ";*/
			sm2 += pk2[i];
		}
		/*cout << endl << sm2 << endl;*/
		cout << min(sm, sm2) << endl;
	return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int a, b;
	string s1, s2;
	cin >> a >> b;
	//cout << (char) (b + '0') << endl;
	for (int i = 1; i <= a; i++)
		s1 += b + '0';
	for (int i = 1; i <= b; i++)
		s2 += a + '0';
	if (s1 < s2)
		cout << s1 << endl;
	else
		cout << s2 << endl;
	return 0;
}


Measured memory_bytes: 256
package main
import (
	"fmt"
	"math"
)

func main(){
	var a, b, angle float64
	fmt.Scan(&a, &b, &angle)


	s :=.5*a*b*math.Sin(math.Pi/180.0*angle)
	fmt.Println(s)
	// 余弦定理
	c := math.Pow(a, 2.0)+math.Pow(b, 2.0)-2.0*a*b*math.Cos(math.Pi/180.0*angle)
	c = math.Sqrt(c)
	fmt.Println(a+b+c)
	// S=1/2(bottoh*hight)
	h := 2.0*s/a
	fmt.Println(h)

}


Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
map<string,int> m;
map<string,int>::iterator it; 
int main()
{
	string str1;
	char sz[11];
	int n,t,i,ma=0;
	scanf("%d",&n);
	getchar();
	for(i=0;i<n;i++)
	{
		scanf("%s",sz);
		str1=sz;
		if(m.count(str1)==0)
		{
			m[str1]=1;
		}
		else
		{
			m[str1]++;
		}
	}
	scanf("%d",&t);
	getchar();
	for(i=0;i<t;i++)
	{
		scanf("%s",sz);
		str1=sz;
		if(m.count(str1)==0)
			m[str1]=-1;
		else
			m[str1]--;
	}
	for(it=m.begin();it!=m.end();it++)
	{
		ma=max(ma,it->second);	
	}
	printf("%d",ma);
	return 0;
}

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

int main() {
  
  int N; cin >> N; int64_t sum = 0;
  
  vector<int> vec(N + 2, 0);
  
  for (int i = 0; i < N; i++) cin >> vec[i + 1];
  
  for (int i = 0; i < N + 1; i++) {
    
    sum += abs(vec[i] - vec[i + 1]);
    
  }
  
  for (int i = 1; i < N + 1; i++) {
    
    int prev = vec[i - 1], present = vec[i], next = vec[i + 1];
    
    int64_t tmp = sum - abs(prev - present) - abs(present - next);
    
    cout << tmp + abs(prev - next) << endl;
    
  }
  
}

Measured memory_bytes: 3752
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<set>
#define ll long long
#define dou(s) atof(s.c_str())
#define lon(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define fion(n) fixed<<setprecision(n)
#define endl "\n"
#define OR ||
#define AND &&
#define NOT !
#define line(s) getline(cin,s)
#define fdarst(a,n) (a[a.size()-1]>=n&&a[lower_bound(ALL(a),n)-a.begin()]==n?lower_bound(ALL(a),n)-a.begin():-1)
#define fist(s,t) ((int)s.find(t))
#define START int main(){cin.tie(0);ios::sync_with_stdio(false);
#define END }
using namespace std;
START
ll n; cin >> n;
vector<ll> a(n);
rep(i, 0, n)cin >> a[i];
ll m; cin >> m;
ll k, ans;
rep(o, 0, m) {
	cin >> k;
	if (fdarst(a, k) != -1)ans++;
}
cout << ans << endl;
END


Measured memory_bytes: 3480
<?php

    // 標準入力を配列化して取得する
    function get_input() {
        $input = [];
        while ($line = fgets(STDIN)) {
            $input[] = trim($line);
        }
        return $input;
    }

    // 末尾に改行をつけて出力
    function output($str) {
        echo $str . PHP_EOL;
    }

    $input = get_input();

    list($sanka, $hyouji) = explode(' ', $input[0]);

    if ($sanka >= 10) {
        $naibu = $hyouji;
    } else {
        // 表示レ = 内部レ - (100 * (10 - $sanka))
        $naibu = $hyouji + (100 * (10 - $sanka));
    }


    output($naibu);




Measured memory_bytes: 4604