akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




bool  compare(pair<string,pll> a, pair<string,pll> b){
    if(a.fi!=b.fi){
        return a.fi<b.fi;
    }
    else{
        return a.sc.fi>b.sc.fi;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n;
    cin>>n;
    string s[200];
    ll p[200];
    pair<string,pll> x[200];
    rep(i,n){
        cin>>s[i]>>p[i];
        x[i]=make_pair(s[i],pll(p[i],i+1));
    }
    sort(x,x+n,compare);
    rep(i,n){
        cout<<x[i].sc.sc<<endl;
    }
    



    return 0;
}

Measured memory_bytes: 256
n = int(input())

a = input()
b = input()
c = input()


def get_intersection(s1, s2):
    # s1とs2のようそすうは同じ

    ret = []

    for i in range(len(s1)):
        if s1[i] == s2[i]:
            ret.append(i)

    return ret


cm_ab = set(get_intersection(a,b))
cm_ac = set(get_intersection(a,c))
cm_bc = set(get_intersection(b,c))


all = set(range(n))
ncm_a = all - (cm_ab | cm_ac)
ncm_b = all - (cm_ab | cm_bc)
ncm_c = all - (cm_ac | cm_bc)


ncm_sum = len(ncm_a)+len(ncm_b)+len(ncm_c)
ncm_all_len = len(all - (cm_ab | cm_bc | cm_ac))

print(ncm_sum - ncm_all_len)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[3][1000007];

int main(){
  string S;
  cin >> S;
  dp[0][0]=0;
  dp[1][0]=1;
  ll X=0;
  rep(i,S.size()){
    X=ctoi(S[i]);
    dp[0][i+1]=min(dp[0][i]+X,dp[1][i]+1+X);
    dp[1][i+1]=min(dp[0][i]+X+1,min(dp[1][i]+10-X-1,dp[1][i]+X+2));
  }
  cout << min(dp[0][S.size()],dp[1][S.size()]+1) << endl;
}

Measured memory_bytes: 17668
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main{

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String[] row = scan.nextLine().split(" ");

        int n = Integer.parseInt(row[0]);
        int q = Integer.parseInt(row[1]);

        Queue<Process> que = new LinkedList<Process>();
        for (int i=0; i<n; i++) {
            String[] strArray = scan.nextLine().split(" ");

            Process process = new Process(strArray[0],
					  Integer.parseInt(strArray[1]));
            que.offer(process);
        }

        int resultTime = 0;
        while (que.size() > 0) {
            Process process = que.poll();
            resultTime += q;
            if ((process.processTime = process.processTime - q) > 0) {

                que.offer(process);
                continue;
            }
            resultTime += process.processTime;

            System.out.println(process.name + " " + resultTime);
        }

    }

    private final static class Process {
        public String name = null;
        public int processTime = 0;

        public Process(String name, int processTime) {
            this.name = name;
            this.processTime = processTime;
        }
    }
}



Measured memory_bytes: 104064
# 133a

def atc_133a(input_value: str) -> int:
    NAB = input_value.split(" ")
    N = int(NAB[0])
    A = int(NAB[1])
    B = int(NAB[2])

    return min(N * A, B)


input_value = input()
print(atc_133a(input_value))


Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
   if(b==0){
       return a;
   }else{
       return gcd(b,a%b);
   }
}
int main()
{
   int N;
   cin >> N;
   int first[100000] = {};
   int last[100000] = {};
   int A[100000] = {};
   int a[100000] = {};
   for(int i=0;i<N;i++){
       cin >> A[i];
       a[i] = A[i];
   }
   reverse(a,a+N);
for(int i=0;i<N;i++){
first[i+1] = gcd(A[i],first[i]);
}
for(int i=0;i<N;i++){
last[i+1] = gcd(a[i],last[i]);
}
int ans = 0;
   for(int i=0;i<=N;i++){
       ans = max(ans,gcd(first[i],last[N-1-i]));
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,X,A[200],u=0,d=0;
  cin >>N>>M>>X;
  for(int i = 0;i < M; i++){
    cin >> A[i];
    if(A[i]>X){u++;}
    else{d++;}
  }
  if(u>d){cout << d <<endl;}
  else{cout << u << endl;}
  return 0;
}
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,i,j;
  while(1){
    cin>>h>>w;
    if(h==0&&w==0){
      break;
    }
    for(i=1;i<=h;i++){
      for(j=1;j<=w;j++){
	if(i%2!=0&&j%2!=0||i%2==0&&j%2==0){
	  cout<<'#';
	  continue;
	}
	cout<<'.';
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return(0);
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
   ll n;
   cin >>n;
   ll a[n],s[n],sum=0;
   for(ll i=0;i<n;i++){
     cin >>a[i];
     sum+=a[i];
     if(i==0) s[i]=a[i];
     else s[i]=(s[i-1]+a[i]);
   }
   ll ans=10000000009;
   for(ll i=0;i<n-1;i++){
       ans=min(ans,abs(sum-2*s[i]));
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 3328
#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>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d



int main() {
    int N, M; cin >> N >> M;
    P ab[M];
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(ab, ab+M);

    int now = 0;
    int cnt = 0;
    REP(i, M) {
        P f = ab[i];
        int l = f.second;
        int r = f.first;
        if (l >= now) {
            cnt++;
            now = r;
        }
    }

    cout << cnt << endl;

    return 0;
}

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<std::vector<ll>> A) {
  vector<vector<ll>> dp(N, vector<ll>(N));
  dp = A;

  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        if (k == i || k == j || i == j) continue;
        if (dp.at(i).at(k) + dp.at(k).at(j) == A.at(i).at(j)) {
          dp.at(i).at(j) = LINF;
        } else if (dp.at(i).at(k) + dp.at(k).at(j) < A.at(i).at(j)) {
          cout << -1 << endl;
          return;
        }
      }
    }
  }

  ll sum = 0;
  rep(i, N) rep(j, N) if (dp.at(i).at(j) != LINF) sum += dp.at(i).at(j);
  cout << sum / 2 << endl;
}

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

  ll N;
  scanf("%lld", &N);
  std::vector<std::vector<ll>> A(N, std::vector<ll>(N));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%lld", &A[i][j]);
    }
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 4856
package main

import (
	"fmt"
	"math"
)

func isPrime(n int) bool {
	var tmp float64 = float64(n)
	rng := int(math.Ceil(math.Sqrt(tmp)))
	// fmt.Printf("rng = %d, n = %d, jajaja = %f\n", rng, n, math.Sqrt(float64(n)))
	for i := 2; i < rng; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	var x int
	fmt.Scan(&x)
	for i := x; i < 100004; i++ {
		if isPrime(i) {
			fmt.Println(i)
			break
		}
	}
}


Measured memory_bytes: 512
from collections import Counter
N = int(input())
A = list(map(int,input().split()))

s = 0
S = [0]
for a in A:
    s += a
    S.append(s)
C = Counter(S)

ans = 0
for c in C.values():
    ans += c * (c-1) // 2
print(ans)

Measured memory_bytes: 113096
ABCD = input()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
if(A+B+C+D == 7):
  print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
  exit()
if(A-B+C+D == 7):
  print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
  exit()
if(A+B-C+D == 7):
  print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
  exit()
if(A+B+C-D == 7):
  print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
  exit()
if(A-B-C+D == 7):
  print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
  exit()
if(A+B-C-D == 7):
  print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
  exit()
if(A-B+C-D == 7):
  print(str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
  exit()
if(A-B-C-D == 7):
  print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
  exit()

Measured memory_bytes: 9308
#define first f
#define second s
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector <int> a(n), b(n-1);
	for (int i = 0; i < n - 1; i++) {
		cin >> b[i];
	}
	a[0] = b[0];
	a[n - 1] = b[n - 2];
	for (int i = 1; i < n-1; i++) {
		a[i] = min(b[i - 1], b[i]);
	}
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += a[i];
	}
	cout << ans;
}

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

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

    int ans=10000;
    for(int i=0;i<(1<<D);i++){
        //cout << i << endl;
        int cur=0;
        int rest=G;
        for(int j=0;j<D;j++){
            if(i & (1<<j)){
                cur += p[j];
                rest -= 100*(j+1)*p[j]+c[j];
            }
        }
        //cout << rest << endl;
        if(rest <= 0){
            //cout << cur << endl;
            ans = min(ans, cur);
            continue;
        }
        for(int j=D-1;j>=0;j--){
            if(!(i & (1<<j))){
                int k=0;
                while(rest>0 && k<=p[j]){
                    cur++;
                    rest -= 100*(j+1);
                    k++;
                }
                if(rest <= 0){
                    //cout << cur << endl;
                    ans = min(ans, cur);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(1e5)+10;
const int INF=0x7f7f7f7f;
int n,m,tr[maxn*4],dp[maxn];
int lazy[maxn*4];
char s[maxn];
vector<int> g[maxn];
void pushdown(int root) {
	if (lazy[root]==INF) return;
	tr[root*2]=min(tr[root*2],lazy[root]);
	tr[root*2+1]=min(tr[root*2+1],lazy[root]);
	lazy[root*2]=min(lazy[root*2],lazy[root]);
	lazy[root*2+1]=min(lazy[root*2+1],lazy[root]);
}
void update(int L,int R,int l,int r,int root,int delta) {
	if (L>R) return;
	if (L<=l&&r<=R) {
		lazy[root]=min(lazy[root],delta);
		tr[root]=min(tr[root],delta);
		return;
	}
	pushdown(root);
	int mid=(l+r)/2;
	if (L<=mid) update(L,R,l,mid,root*2,delta);
	if (mid<R) update(L,R,mid+1,r,root*2+1,delta);
	tr[root]=min(tr[root*2],tr[root*2+1]);
}
int query(int x,int l,int r,int root) {
	if (l==r) return tr[root];
	pushdown(root);
	int mid=(l+r)/2;
	if (x<=mid) return query(x,l,mid,root*2);
	return query(x,mid+1,r,root*2+1);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	scanf("%s",s+1); n++;
	memset(lazy,INF,sizeof(lazy));
	memset(tr,INF,sizeof(tr));
	update(n,n,1,n,1,0);
	for (int i=n;i>=1;i--) {
		if (s[i]=='1') { dp[i]=INF; continue; }
		dp[i]=query(i,1,n,1);
		update(max(1,i-m),i-1,1,n,1,dp[i]+1);
	}
	if (dp[1]==INF) { printf("-1\n"); return 0; }
	for (int i=1;i<=n;i++) {
		if (dp[i]!=INF) g[dp[i]].push_back(i);
	}
	int pos=1,tmp,x;
	while (pos<n) {
		x=dp[pos]-1;
		tmp=*lower_bound(g[x].begin(),g[x].end(),pos+1);
		printf("%d ",tmp-pos);
		pos=tmp;
	}
	printf("\n");
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 9472
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <math.h>

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

  string s;
  cin >> s;

  bool found[26] = {false};
  for (char c : s) {
    found[c - 'a'] = true;
  }

  for (int i = 0; i < 26; ++i) {
    if (!found[i]) {
      const char c = i + 'a';
      cout << c << endl;
      return 0;
    }
  }
  cout << "None" << endl;

  return 0;
}


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

int main(void){
    int i,j,min,n,tmp,cnt=0;
    int a[100];
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    
    for(i=0;i<n-1;i++){
        min=i;
        for(j=i+1;j<n;j++){
            if(a[min]>a[j]){
                min=j;
            }
        }
        if(min!=i){
            tmp=a[min];
                a[min]=a[i];
                a[i]=tmp;
                cnt++;
        }
    }
    
    for(i=0;i<n-1;i++){
        cout<<a[i]<<" ";
    }
    cout<<a[n-1]<<endl<<cnt<<endl;
    
    return 0;
}
    


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

static const ll INF = 1e15;

static const ll mod= 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	vector<char> cs;
	cs.reserve(n);
	rep(i, n - 1) {
		if (s[i] == 'B' && s[i + 1] == 'C') {
			cs.push_back('D');
			i++;
			continue;
		}
		else {
			cs.push_back(s[i]);
		}
	}
	auto csSize = cs.size();
	ll total = 0;
	int aCount = 0;
	rep(i, csSize) {
		if (cs[i] == 'A') {
			aCount++;
		}
		else if (cs[i] == 'D') {
			total += aCount;
		}
		else {
			aCount = 0;
		}
	}
	cout << total << endl;
	return 0;
}
	

Measured memory_bytes: 3868
$n=<>;
$min=1e5;
@DP=(2e5)x($n);
$DP[0]=0;
for$i(1..$n){
    $DP[$i] = $DP[$i-1] +1;
    for($j=1;$j<=$i;$j*=6){$DP[$i] = $DP[$i]<$DP[$i-$j]+1?$DP[$i]:$DP[$i-$j]+1}
    for($j=1;$j<=$i;$j*=9){$DP[$i] = $DP[$i]<$DP[$i-$j]+1?$DP[$i]:$DP[$i-$j]+1}
}
print$DP[$n];


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

int main() {

  long long int n;
  cin >> n;

  long long int a[2][101] = {};

  for ( int i = 0; i < 2; i++ ) {
    for ( int j = 0; j < n; j++ ) {

      cin >> a[i][j]; 
      long long int k = 0;
      if ( j > 0 ) k = max( k, a[i][j-1] );
      if ( i > 0 ) k = max( k, a[i-1][j] );
      a[i][j] += k;

    }
  }

  cout << a[1][n-1] << endl;

  return 0;

}


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

int N, Q;
int p, x;
vector<int> counter;
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;
    for(auto next_v : G[v]){
        if(seen[next_v]) continue;
        counter[next_v] += counter[v];
        dfs(G, next_v);
    }
}

int main(){
    cin >> N >> Q;
    Graph G(N);
    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    counter.resize(N);    
    for (int i = 0; i < Q; i++)
    {
        cin >> p >> x;
        p--;
        counter[p] += x;
    }

    seen.assign(N, false);
    dfs(G, 0);
    
    for (int i = 0; i < N; i++)
    {
        cout << counter[i];
        if(i == N - 1) cout << endl;
        else cout << " ";
    }
    
}

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

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

  if (a >= b) {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
  } else {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    string ans = "No";

    for (int i = 0; i <= (n / 4); ++i) {
        for (int j = 0; j <= (n / 7); ++j) {
            if (4 * i + 7 * j == n) {
                ans = "Yes";
                break;
            }
        }
        if (ans == "Yes") break;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program
{
  static void Main(string[] args)
  {
    int a = 0;
    int n = int.Parse(Console.ReadLine());
    string[] strh = Console.ReadLine().Split(' ');
    int[] h = Array.ConvertAll(strh, int.Parse);
	for(int i = 0; i < n; i++)
    {
      bool candidate = true;
      for (int j = 0; j < i; j++)
      {
        if(h[i] < h[j])
        {
          candidate = false;
          break;
        }
      }
      if (candidate)
      {
        a++; 
      }  
    }
    Console.WriteLine(a);
  }
}

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

using namespace std;

ll n,a,b,p,q;

int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	for(int i=1;i<n;i++)
	{
		scanf("%lld%lld",&p,&q);
		a=(a/p+(a%p!=0))*p;
		if(b<=a/p*q)b=a/p*q;
		else
		{
			b=(b/q+(b%q!=0))*q;
			a=b/q*p;
		}
	}
	printf("%lld",a+b);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
 
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};
 
#define MAX_LOG_N 18
 
int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 
  int N; cin >> N;
  vector<int> hotels(N); REP(i, N) cin >> hotels[i];
  int L, Q; cin >> L >> Q;
  vector<int> A(Q), B(Q); REP(i, Q) cin >> A[i] >> B[i], A[i]--, B[i]--;
  vector<vector<int>> left(2, vector<int>(N)), next_hotel(2, vector<int>(N));
  REP(i, N) left[0][i] = hotels[i] - hotels[0];
  for (int i = N-1; i >= 0; i--) left[1][N-1-i] = hotels[N-1] - hotels[i];
 
  //REP(k, 2) REP(i, N) cout << left[k][i] << (i == N-1 ? '\n' : ' ');
  REP(k, 2) REP(i, N) {
    auto c = lower_bound(ALL(left[k]), left[k][i] + L);
    if (c == left[k].end()) {
      next_hotel[k][i] = N-1;
    } else {
      int idx = c - left[k].begin();
      next_hotel[k][i] = left[k][idx] > left[k][i] + L ? idx-1 : idx;
    }
  }
 
  // doubling
  vector<vector<vector<int>>> doubling(2, vector<vector<int>>(MAX_LOG_N, vector<int>(N, -1)));
  REP(k, 2) REP(i, N) doubling[k][0][i] = next_hotel[k][i];
  REP(k, 2) REP(i, MAX_LOG_N-1) REP(j, N) doubling[k][i+1][j] = doubling[k][i][j] < 0 ? -1 : doubling[k][i][doubling[k][i][j]];
 
  /*
  REP(k, 2) REP(i, N) cout << left[k][i] << (i == N-1 ? '\n' : ' ');
  cout << endl;
  REP(k, 2) {
    REP(i, MAX_LOG_N) REP(j, N) cout << doubling[k][i][j] << (j == N-1 ? '\n' : ' ');
    cout << endl;
    } //*/
 
  REP(q, Q) {
    int ans = 0;
    int k = A[q] < B[q], a = A[q], b = B[q];
    swap(a, b);
    if (a > b) {
      a = N-1 - a;
      b = N-1 - b;
    }
    //cout << a << ' ' << b << endl;
    assert(a < b);
 
    for (int i = MAX_LOG_N-1; i >= 0; i--) {
      if (doubling[k][i][a] < b) {
        ans += 1 << i;
        a = doubling[k][i][a];
      }
    }
    printf("%d\n", ans+1);
  }
 
  return 0;
}

Measured memory_bytes: 25080
#include <iostream>
#include <set>

using namespace std;

int main()
{
	int n;
	cin >> n;
	set<int> s;
	int t;
	for (int i = 0; i < n; i++) {
		cin >> t;
		s.insert(t);
	}
	cout << s.size() << endl;

	return 0;
}

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


Measured memory_bytes: 3080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace attocoda
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (a == b && b != c)
                Console.WriteLine(c);
            else if (b == c && b != a)
                Console.WriteLine(a);
            else
                Console.WriteLine(b);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
fun main(arg: Array<String>) {
    var S = next()
    var L = S.length
    var M = mutableListOf<Char>()
    var n = 0
    var c=0
    while (n < L) {
        M.add(S[n++])
        if (M.size >= 2 && M[M.lastIndex-1] == 'S' && M[M.lastIndex] == 'T') {
             M.removeAt(M.lastIndex)
             M.removeAt(M.lastIndex)
            c++
}
}
    println(L - (2 * c))
}
fun next() = readLine()!!

Measured memory_bytes: 39000
S = input()
T = input()
length = len(S)
flg = 1
dic = {}
for i in range(length):
    data = S[i]
    if S[i] not in dic:  dic[S[i]] = T[i]
    else:
        if dic[S[i]] != T[i]:  flg = 0

dic = {}
for i in range(length):
    data = T[i]
    if T[i] not in dic:  
        dic[T[i]] = S[i]
    else:
        if dic[T[i]] != S[i]:  flg = 0
                
if flg:  print("Yes")
else:  print("No")

Measured memory_bytes: 68540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

struct RollingHash {
    static const int base1 = 1007, base2 = 2009;
    static const int mod1 = 1000000007, mod2 = 1000000009;
    vector<long long> hash1, hash2, power1, power2;

    // construct
    RollingHash(const vector<LL> &S) {
        int n = (int)S.size();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        power1.assign(n+1, 1);
        power2.assign(n+1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i+1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + S[i]) % mod2;
            power1[i+1] = (power1[i] * base1) % mod1;
            power2[i+1] = (power2[i] * base2) % mod2;
        }
    }
    
    // get hash of S[left:right]
    inline pair<long long, long long> get(int l, int r) const {
        long long res1 = hash1[r] - hash1[l] * power1[r-l] % mod1;
        if (res1 < 0) res1 += mod1;
        long long res2 = hash2[r] - hash2[l] * power2[r-l] % mod2;
        if (res2 < 0) res2 += mod2;
        return {res1, res2};
    }
};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    VL a(N),b(N);
    REP(i,N) cin >> a[i];
    REP(i,N) cin >> b[i];
    VL da(N*2),db(N*2);
    REP(i,N*2){
        int j = i % N;
        int k = (i+1) % N;
        da[i] = a[j]^a[k];
        db[i] = b[j]^b[k];
    }
    RollingHash A(da),B(db);
    REP(k,N){
        if(A.get(k,k+N-1) == B.get(0,N-1)){
            cout << k << " "   << (a[k] ^ b[0]) << endl;
        }
    }

}


Measured memory_bytes: 37888
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int N;
vector<int> v;
int main() {
	cin >> N;
	for (int i = 0; i <= 100000000; ++i) {
		if (i*(i + 1) / 2 >= N) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s[3];
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
  }

  int turn = 0;
  while(true) {
    int now = turn;
    if (s[now].empty()) break;
    turn = s[now][0] - 'a';
    s[now].erase(0, 1);
  }
  
  if (turn == 0) cout << 'A' << endl;
  else if (turn == 1) cout << 'B' << endl;
  else cout << 'C' << endl;
}

Measured memory_bytes: 256
import numpy as np
n=int(input())
x1=list(map(int,input().split()))
ans=1000000000000000000000
for i in np.arange(1,101):
    hp=0
    for j in x1:
        hp+=(j-i)*(j-i)
    if hp<=ans:
        ans=hp
print(ans)

Measured memory_bytes: 26956
N = int(input())
S = input()

D = {}
for s in S :
    if s not in D :
        D[s] = 1
    else :
        D[s] += 1

L = sorted(list(D.values()))

ans = 1
if N == 1 :
    ans = 1
elif len(L) == 1 :
    ans = L[0]
else :
    for i in range(len(L)) :
        ans *= (1+L[i])
        ans %= (10**9+7)
    ans -= 1
ans %= (10**9+7)
print(ans)



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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

int n;
string s;

int sosu[1000];
ll a[1000];
int N;

void init()
{
	sosu[0] = 2;
	int cnt = 0;
	for (int i = 3; i < 1000 ; i++) {
		bool f = true;
		rep(j, cnt+1) {
			if (i % sosu[j] == 0) {
				f = false;
				break;
			}
		}
		if (f) {
			sosu[++cnt] = i;
		}
	}
	cin >> N;
}



void solve()
{
	reps(i, 1, N+1) {
		int t = i;
		for (int j = 0; t != 1;) {
			if (t % sosu[j] == 0) {
				t /= sosu[j];
				a[sosu[j]]++;
			} else j++;
		}
	}
	ll res = 1;
	rep(i, 1000) {
		res = res * (a[i]+1) % MOD;
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;



int main() {
    Int n;
    cin >> n;
    string ans = "";
    while (n > 0) {
        n--;
        int r = n % 26;
        ans += r + 'a';
        n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3588
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
AB = []
for i in range(n):
    a,b = readInts()
    AB.append((a,b))
cnt = 0
for i in range(n-1,-1,-1):
    a,b = AB[i]
    a += cnt
    cnt += (b - a%b) if a%b else 0
print(cnt)


Measured memory_bytes: 23684
import numpy as np
c = [list(map(int, input().split()))for i in range(3)]
c = np.array(c)
c1 = c[0][0] - c[1][0]
c2 = c[0][0] - c[2][0]

if all(c[1]+c1 == c[0]) and all(c[2]+c2 == c[0]):
    print('Yes')
else:
    print('No')

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

int main(void){
    int a,b,c,cnt,a0,b0,c0;
    cnt = 0;
    cin >> a >> b >> c;


    if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){
        cout << cnt << endl;
    }else if(a == b && b == c){
        cout << -1 << endl;
    }else{
        while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
            a0 = a, b0 = b , c0 = c; 
            a = ( b0 + c0 ) / 2;
            b = ( a0 + c0 ) / 2;
            c = ( a0 + b0 ) / 2;
            cnt++;
        }
        cout << cnt << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
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);

  int n;
  cin >> n;
  vector<int> l(n);
  rep(i, n) cin >> l[i];

  sort(l.rbegin(), l.rend());

  int sum = 0;
  rep(i, n-1) {
    sum += l[i+1];
  }
  if (sum > l[0]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll ret = 0;

void input() {
  IN(N);
}

ll getMax(ll digit) {
  if (digit <= 0) return 0;
  ll ret = 9;
  REP(i, digit-1) {
    ret *= 10;
    ret += 9;
  }
  return ret;
}

void solve() {
  ll ans = 0;
  ll digit = 1;
  ll n = 1;
  while(getMax(digit)<N) {
    ans += getMax(digit) - getMax(digit-1);
    digit += 2;
    n *= 100;
  }
  if (N >= n) {
    ans += N - getMax(digit-1);
  }
  PRINT(ans);
}

int main(void){
  input();
  solve();
}


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

int main(){
  int X,Y;
  cin >> X >> Y;
  bool a=false;
  for(int i=2*X;i<4*X+1;i+=2){
    if(i==Y){
      a=true;
      break;
    }
  }
  if(a){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL k;
    LL s;
    LL ans=0;
    cin >> k >> s;
    for(LL i=0; i<=k; i++){
        for(LL j=0; j<=k; j++){
            LL l=s-i-j;
            if(l>=0 && l<=k){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#define _DEBUG
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//デバッグ
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug1(x1) cout<<#x1<<": "<<x1<<endl
#define debug2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug5,debug4,debug3,debug2,debug1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

//Olog(N)
//最初に初期化
//vl minfac=sieve(N+1);
//次に計算
//map<ll,ll> fac=factor(N,minfac);
//結果はmapで渡される（ただしN=1の時値なしなので注意）
// for(auto itr=fac.begin();itr!=fac.end();itr++){
//     cout<<itr->first<<" "<<itr->second<<endl;
// }
std::vector<ll> sieve(ll n) {
  std::vector<ll> res(n);
  std::iota(res.begin(), res.end(), 0);
  for (ll i = 2; i*i < n; ++i) {
    if (res[i] < i) continue;
    for (ll j = i*i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}

std::map<ll,ll> factor(ll n, const std::vector<ll>& min_factor) {
  // min_factor は sieve() で得られたものとする
  std::map<ll,ll> res;
  while (n > 1) {
    res[min_factor[n]]++;
    n /= min_factor[n];
    // 割った後の値についても素因数を知っているので順次求まる
  }
  return res;
}

int main(){
    ll N;
    cin>>N;
    ll ans=0;
    ll tmp=0;
    REP2(a,1,N){
        REP2(b,1,N){
            if(N-a*b<=0) break;
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

const int inf = INT_MAX;
vector<int> pos;
vector<vector<pair<int, int>>> edge;

bool check(int src)
{
    for (int i = 0; i < edge[src].size(); i++)
    {
        int dst = edge[src][i].first;
        int d = edge[src][i].second;

        if (pos[dst] == inf)
        {
            pos[dst] = pos[src] + d;
            if (check(dst) == false)
            {
                return false;
            }
        }
        else if (pos[dst] != pos[src] + d)
        {
            return false;
        }
    }

    return true;
}

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

    edge = vector<vector<pair<int, int>>>(N, vector<pair<int, int>>());
    for (int i = 0; i < M; i++)
    {
        int L, R, D;
        cin >> L >> R >> D;
        L--;
        R--;
        edge[L].push_back(make_pair(R, D));
        edge[R].push_back(make_pair(L, -D));
    }

    pos = vector<int>(N, inf);
    for (int i = 0; i < N; i++)
    {
        if (pos[i] != inf)
        {
            continue;
        }

        pos[i] = 0;
        if (check(i) == false)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 11008
#include<iostream>
#include<set>
using namespace std;
 
int main() {  
  int N,A,ans=0;
  cin>>N;
  
  set<int> s;
  set<int>::iterator ite;;
  
  for(int i=0;i<N;i++){
    cin>>A;
    ite=s.find(A);
    if(ite==s.end())s.insert(A);
    else s.erase(A);
  }
  
  for(ite=s.begin();ite!=s.end();++ite){
    //cout<<*ite;
    ans+=1;
  }
  cout<<ans;
}

Measured memory_bytes: 4864
#include<iostream>
#include<vector>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define ll long long
#define MOD 1000000007

ll calc(ll a, ll b){
    ll ma=a%MOD, mb=b%MOD;
    return (ma*mb) % MOD;
}

int main(){
    int n; std::cin >> n;
    std::vector<ll> a(n), b(n+1,0);
    rep(i,n){
        std::cin >> a[i];
        b[i+1] = b[i] + a[i];
    }

    ll ans=0;
    for(int i=0; i<n; ++i){
        ll s = (b[n] - b[i+1]) % MOD;
        ans += a[i]*s;
        ans %= MOD;
    }

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

Measured memory_bytes: 6416
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    ll n,T;
    cin>>n>>T;
    vector<ll> t(n);
    for(int i=0;i<n;i++) cin>>t[i];
    t.push_back(1e10);
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=min(T,t[i+1]-t[i]);
    }
    cout<<ans<<endl;
}

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

int S[510][510];
int main()
{
    int N, M, Q; cin>>N>>M>>Q;

    for(int i=0; i<M; ++i) {
        int l, r; cin>>l>>r;
        S[l][r]++;
    }
    for(int l=1; l<=500; ++l)
        for(int r=1; r<=500; ++r)
            S[l][r]+=S[l][r-1];

    for(int p, q, res; Q--; cout<<res<<'\n') {
        cin>>p>>q;
        res=0;
        for(int i=p; i<=q; ++i) res+=S[i][q]-S[i][p-1];
    }
}


Measured memory_bytes: 1920
#include<iostream>
using namespace std;
int main(void)
{
	char s[5];
	int i;
	for(i=1;i<=4;i++){
		cin>>s[i];
	}
	if(s[1]==s[2] || s[2]==s[3] || s[3]==s[4]) cout<<"Bad"<<endl;
	else cout<<"Good"<<endl;
	return 0;
}

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

int main() {
  int64_t n,a,b;
  cin >> n >> a >> b;
  int64_t ans = 0;
  ans += (n/(a+b))*a;
  if(n%(a+b)<=a) ans += n%(a+b);
  else ans += a;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << a * b /2 << endl;
    return 0;
}

Measured memory_bytes: 256
// Author : Harshdeep Sharma , IIT Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();

// function to calculate any numbered power of some number without modulo
ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}
// function to check whether a bracketed sequence is balanced or not
bool isBalanced(const string &exp) {
	// Initialising Variables
	bool flag = true;
	int count = 0;

	// Traversing the Expression
	for (int i = 0; i < exp.length(); i++) {

		if (exp[i] == '(') {
			count++;
		}
		else {
			count--;
		}
		if (count < 0) {
			flag = false;
			break;
		}
	}
	if (count != 0) {
		flag = false;
	}

	return flag;
}
// function to sort by second in a set of pairs
bool sortbysec(const pair<pair<int, int>, int> &a,
               const pair<pair<int, int>, int> &b) {
	return (a.second < b.second);
}

void uniformly_distribute_k_numbers_in_a_square_grid(int n , int k ) {
	int p = 0 , q = 0 ;
	vector<vector<int>> a(n, vector<int>(n)) ;
	for (int i = 1 ; i <= k ; ++i ) {
		a[p][q] = 1 ;
		p = p + 1 ;
		q = (q + 1) % n ;
		if (p == n) {
			p = 0  ;
			q = (q + 1) % n ;

		}
	}
}

ll f(ll n) {
	ll res ;
	if (n % 2 != 0) {
		ll pairs = (n + 1) / 2 ;
		if (pairs % 2 == 0) {
			res = 0  ;
		} else {
			res = 1 ;
		}
	} else {
		// cout << "i\n";
		ll pairs = n / 2 ;
		if (pairs % 2 == 0) {
			res = 0  ;
		} else {
			res = 1 ;
		}
		res ^= n ;
	}
	return res ;
}



// main funtion
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t ;
	// cin >> t ;
	// while (t--) {

	int n  , l ;
	cin >> n >> l ;
	int total = 0 ;
	int mn = 500 ;
	for (int i = 0 ; i < n ; i++) {
		total += (l + i) ;
		mn = min(mn , abs(l + i)) ;
	}
	// cout << total << " " << mn << "\n";
	if (total > 0) cout << total - mn << "\n";
	else cout << total + mn << "\n";








	// }







	return 0 ;
}


Measured memory_bytes: 3628
def checkSorted(n,l):
    f=0
    s=0
    count=0
    for i in range(1,n):
        if l[i]<l[i-1]:
            count+=1
            if f==0:
                f=i
            else:
                s=i
    if count>2:
        return 0
    if count==0:
        return 1
    if count==2:
        l[f-1],l[s]=l[s],l[f-1]
    elif count==1:
        l[f-1],l[f]=l[f],l[f-1]
    for i in range(1,n):
        if l[i]<l[i-1]:
            return 0
    return 1
n=int(input())
l=list(map(int,input().split()))
if checkSorted(n,l)==1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n,k,h[100005],x,y,ans=0;
bool ch;
map<int,vector<int> >a;
int main()
{
	cin>>n>>k;
	rep(i,n) cin>>h[i];
	rep(i,k)
	{
		cin>>x>>y;
		a[x].pb(y);
		a[y].pb(x);
	}
	rep(i,n)
	{
		
		if(!a.count(i+1)) ans++;
		else
		{
			ch=0;
			rep(j,a[i+1].size())
			{
				if(h[i]<=h[a[i+1][j]-1])
				{
					ch=1;break;
				}
			}
			if(!ch) ans++;
		}
	}
	re(ans)
	return 0;}

Measured memory_bytes: 13564