akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define VIN(n,v) for(int64_t i=0;i<(n);i++){cin >> (v).at(i);}

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

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

int ctoi(char c){
  return c - '0';
}

int main(){
  string s;
  cin >> s;
  string now,prev;
  I t=0;
  for(auto c:s){
    now += c;
    if (prev != now){
      prev = now;
      now = "";
      t++;
    }
  }
  cout << t << endl;
  return 0;
}



Measured memory_bytes: 640
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String str = sc.next();
            switch(str){
              case "MON":
                System.out.println(6);
                break;
              case "TUE":
                System.out.println(5);
                break; 
              case "WED":
                System.out.println(4);
                break;
              case "THU":
                System.out.println(3);
                break;  
              case "FRI":
                System.out.println(2);
                break;
              case "SAT":
                System.out.println(1);
                break;
              case "SUN":
                System.out.println(7);
                break;                                           
            }
      }
}

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

int main(int argc, const char * argv[]) {
    string s;cin>>s;
 
    int half=(int)s.size()/2 + s.size()%2;
    int p=0,g=0;
    for(int i=0;i<half;i++){
        if(s[i]=='p')p++;
    }
    for(int i=half;i<s.size();i++){
        if(s[i]=='g')g++;
    }
    
    cout<<g-p<<endl;
    
    return 0;
}


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

const int MAX_N = 2e5 + 5;

int N, t[MAX_N], T;

int main()
{
  #ifdef OJ
    freopen("/home/linjian/Documents/cpp_programs/in.txt", "r", stdin);
  #endif
  cin >> N >> T;
  for (int i = 0; i < N; ++i) {
    scanf("%d", t + i);
  }
  t[N] = INT_MAX;
  ll s = 0;
  int l = t[0], r;
  for (int i = 0; i < N; ++i) {
    if (t[i + 1] > t[i] + T) {
      r = t[i] + T;
      s += r - l;
      l = t[i + 1];
    }
  }
  printf("%lld\n", s);
  return 0;
}

Measured memory_bytes: 1024
// BROWNIE TK
 
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define osetlli tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
#define ofk order_of_key
#define fbo find_by_order

using namespace std;
 
/*STD fucntions*/
lli power(lli x,lli y,lli p)
{
    lli res=1;
    x=x%p;
    while(y>0)
    {
        if(y&1)
            res=(res*x)%p;
        //y must be even now
        y=y>>1; //y=y/2
        x=(x*x)%p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli modi(lli a,lli m)
{
// fermat little thm where m is prime
return power(a,m-2,m);
}
/*CODE BEGINS*/
int main()
{
 kira;
 lli n;
 cin>>n;
 lli a[n];
 forz(i,n)cin>>a[i];
 lli dp[n][n]={0};
 for(int l=n-1;l>=0;l--)
 {
   for(int r=l;r<n;r++)
   {
     if(r==l)dp[l][r]=a[r];
     else
     {
       dp[l][r]=max(a[r]-dp[l][r-1],a[l]-dp[l+1][r]);
     }
   }
 }
 cout<<dp[0][n-1];
 return 0;
}

Measured memory_bytes: 70656
#include <stdio.h>
int main(){
    long int a;
    long double b;
    scanf("%ld %Lf", &a, &b);
    
    //printf("%d %f\n", a, b);
    long double tmp = a * b;
    //printf("%Lf\n", tmp);
    long int ans = tmp;
    printf("%ld\n", ans);

    return 0;
}


Measured memory_bytes: 1752
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll s,w;
    cin>>s>>w;
    if(s<=w){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 302;

ll add(ll x,ll y)
{
    return (x + y)%MOD;
}

ll sub(ll x,ll y)
{
    return (x+MOD-y)%MOD;
}

ll mul(ll x,ll y)
{
    return x*y%MOD;
}

int dp[MAX_N][MAX_N][MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    dp[0][1][1] = 1;
    rep(i,m){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=j;k++){
                dp[i+1][j+1][k] = add(dp[i+1][j+1][k],mul(dp[i][j][k],n-j));
                dp[i+1][j][j] = add(dp[i+1][j][j],mul(dp[i][j][k],k));
                dp[i+1][j][k] = add(dp[i+1][j][k],mul(dp[i][j][k],j-k));
            }
        }
    }
    cout << dp[m][n][n] << "\n";
    return 0;
}


Measured memory_bytes: 107136
#include <stdio.h>

using namespace std;

int main(){
	int n,x;
	scanf("%d",&n);

	for(int i = 1; i<= n; i++)
	{
		if(i%3 == 0){
			printf(" %d",i);
		}else{
			x = i;
			do{
				if(x%10 == 3){
					printf(" %d",i);
					break;
				}
				x /=10;
			}while(x);
		}
	}
	printf("\n");
}


Measured memory_bytes: 2716
#include <stdio.h>
#include <string.h>

void swap(char *x,char *y){
    char c;
    c=*x;
    *x=*y;
    *y=c;
}

int main() {
    char S[100], T[100];
    int i=0, j=0;
    scanf("%s", S);
    scanf("%s", T);
    while(1){
        if(strcmp(S, T)==0){
            printf("Yes\n");
            break;
        }
        if(i > strlen(S)){
            printf("No\n");
            break;
        }
        swap(&S[0], &S[strlen(S)-1]);
        for(j=(int)strlen(S)-1;j>1;--j){
            swap(&S[j], &S[j-1]);
        }
        ++i;
    }

    return 0;
}

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

#define INF 10000000000
using namespace std;

template <class Abel> struct BIT {
    const Abel UNITY_SUM = 0;                       // to be set
    vector<Abel> dat;
    
    /* [1, n] */
    BIT(int n) : dat(n + 1, UNITY_SUM) { }
    void init(int n) { dat.assign(n + 1, UNITY_SUM); }
    
    /* a is 1-indexed */
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            dat[i] = dat[i] + x;
    }
    
    /* [1, a], a is 1-indexed */
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i)
            res = res + dat[i];
        return res;
    }
    
    /* [a, b), a and b are 1-indexed */
    inline Abel sum(int a, int b) {
        return sum(b - 1) - sum(a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};



int main() {
    int N, Q; cin >> N >> Q;
    BIT<int> bit(N);
    for (int query = 0; query < Q; ++query) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) bit.add(x, y);
        else cout << bit.sum(x, y+1) << endl;
    }
}


Measured memory_bytes: 3128
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String  moji = sc.nextLine();
        String moji2 = moji.substring(0,(moji.length()-1)/2);
        String moji3 = moji.substring((moji.length()+1)/2,moji.length());

        //System.out.println(moji2);
        //System.out.println(moji3);

        String flag = "No";

        if(moji2.equals(moji3)) flag = "Yes";
        System.out.println(flag);

    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main(void)
{
	int n, i, x;
	list<int> L;
	scanf("%d", &n);
	char command[20];
	for (i = 0; i < n; i++)
	{
		scanf("%s", command);
		if (command[0] == 'i') // insert x
		{
			scanf("%d", &x);
			L.push_front(x);
		}
		else if (command[6] == 'F') // deleteFirst
		{
			L.pop_front();
		}
		else if (command[6] == 'L') // deleteLast
		{
			L.pop_back();
		}
		else if (command[0] = 'd') // delete
		{
			scanf("%d", &x);
			for (list<int>::iterator it = L.begin(); it != L.end(); it++)
			{
				if (*it == x) 
				{
					L.erase(it);
					break;
				}
			}
		}
	}
	i = 0;
	for (list<int>::iterator it = L.begin(); it != L.end(); it++)
	{
		if (i++ > 0) cout << " ";
		cout << *it; 
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 34492
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void) {
	
	int a;
	scanf("%d",&a);
	
	int b;
	scanf("%d",&b);
	int h;
	scanf("%d",&h);
	
	printf("%d",(a+b)*h/2);
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005][5],dp[100005][5];
long long solve(long long i,long long k)
{
    if(i>n)
    return 0;
    if(dp[i][k]!=-1)
    return dp[i][k];
    if(k==0)
    dp[i][k]=max(solve(i+1,1)+a[i][1],max(solve(i+1,2)+a[i][2],solve(i+1,3)+a[i][3]));
    if(k==1)
    dp[i][k]=max(solve(i+1,2)+a[i][2],solve(i+1,3)+a[i][3]);
    if(k==2)
    dp[i][k]=max(solve(i+1,1)+a[i][1],solve(i+1,3)+a[i][3]);
    if(k==3)
    dp[i][k]=max(solve(i+1,1)+a[i][1],solve(i+1,2)+a[i][2]);
    return dp[i][k];
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=3;j++)
        cin>>a[i][j];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=3;j++)
        dp[i][j]=-1;
    }
    cout<<solve(0,0);
}

Measured memory_bytes: 14336
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//_|

int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i,n,an,cn;
	cin>>n;
	
	vector<int> a(n,0),b(n,0),c(n,0);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n)cin>>c[i];
	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());
//	rep(i,n)cout<<a[i]<<" ";
//	cout<<endl;
//	rep(i,n)cout<<b[i]<<" ";
//	cout<<endl;
//	rep(i,n)cout<<c[i]<<" ";
//	cout<<endl;
	
	ll ans=0;
	rep(i,n){
		an=(lower_bound((a).begin(),(a).end(), b[i])-a.begin());
		cn=c.end()-upper_bound((c).begin(),(c).end(), b[i]);
		ans+=(ll)an*cn;
//		cout<<an<<" "<<cn<<endl;
	}
	fin(ans);
	
	
//////////////////////////////////////////////////////
return 0;}











Measured memory_bytes: 1536
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(ll __x = __start; __x < __end; __x++)

typedef pair<int, int> P;
int main() {
  int h, w, n; cin >> h >> w >> n;
  int G[101][101];
  vector<P> A;
  loop(i,0,n) {
    int a;
    cin >> a;
    loop(j,0,a) A.emplace_back(a, i+1);
  }
  sort(A.rbegin(), A.rend());
  int idx = 0;
  loop(y,0,h) {
    int init,end,step;
    if (y%2==0) init = 0,end=w,step=1;
    else init=w-1,end=-1,step=-1;
    for (int x = init; x != end; x += step) {
      G[y][x] = A[idx++].second;
    }
  }
  
  loop(y,0,h) {
    loop(x,0,w) {
      if (x != 0) cout << " ";
      cout << G[y][x];
    }
    cout << endl;
  }
  
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll a[214514];
	cin>>n;
	REP(i, n){
		cin>>a[i];
	}
	sort(a, a+n);
	int ans=0;
	map<ll, int> used;
	FORR(i, 0, n){
		ll m=2*a[i];
		if(!(m&(m-1))){
			int tmp=upper_bound(a, a+n, a[i])-lower_bound(a, a+n, a[i]);
			if(tmp>0 && tmp-used[a[i]]-1>0){
				++ans;
				used[a[i]]+=2;
			}
		}
		else{
			m=a[i];
			int cnt=0;
			while(m>0){
				m/=2;
				++cnt;
			}
			ll beki=1ll<<cnt;
			ll b=beki-a[i];
			int tmp1=upper_bound(a, a+n, a[i])-lower_bound(a, a+n, a[i]);
			if(tmp1-used[a[i]]<=0){
				continue;
			}
			int tmp=upper_bound(a, a+n, b)-lower_bound(a, a+n, b);
			if(tmp>0 && tmp-used[b]>0){
				++ans;
				++used[b];
				++used[a[i]];
			}
		}
		// DEBUG(ans);
	}
	cout<<ans<<'\n';
	return 0;
}


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

int n,w;
int a[N],b[N];
ll dp[101][N];

ll fun(int i,int weight)
{
if(dp[i][weight]!=-1) return dp[i][weight];

ll res = 0;

if(i>=n) return 0;

else if(weight<a[i]) res = fun(i+1,weight);

else res = max(fun(i+1,weight), fun(i+1,weight-a[i])+b[i]);

dp[i][weight] = res; 

return res ;
}

int main()
{
memset(dp,-1,sizeof(dp));

cin >> n >> w;

for(int i=0;i<n;i++) cin >> a[i] >> b[i];

ll ans = fun(0,w);

cout << ans << '\n';

return 0;
}

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

using namespace std;

int gcd(int a, int b)
{
	return (a % b == 0 ? b : gcd(b, a % b));
}

int main()
{
	int x, y;
	cin >> x >> y;
	cout << x + y - gcd(x, y) + 1 << endl;

	return 0;
}



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

mul = 1

A.sort()

for i in range(N):
  mul *= A[i]
  if mul == 0 or mul > 10 ** 18:
    break

if mul > 10 ** 18:
  print('-1')
else:
  print(mul)

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

using namespace std;

void Game(int target);

string str[3]={};

int main(){
    for(int i=0;i<3;i++){
        cin >> str[i];
    }
    Game(0);
    return 0;
}

void Game(int target){
    if(str[target].empty()==true){
        switch(target){
            case 0:
            cout << "A" << endl;
            break;
            case 1:
            cout << "B" << endl;
            break;
            case 2:
            cout << "C" << endl;
            break;
        }
        return;
    }
    char nextTarget=str[target].front();
    str[target].erase(0,1);
    switch(nextTarget){
        case 'a':
        Game(0);
        break;
        case 'b':
        Game(1);
        break;
        case 'c':
        Game(2);
        break;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int a[200010];

int main() {
    ios_base::sync_with_stdio(0);
    int n; cin >> n;
    for (int i=0;i<n;i++) cin >> a[i];

    ll ans = 0;
    for (int i=1;i<n;i++) {
        int diff = max(0, a[i-1]-a[i]);
        ans += diff; a[i] += diff;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n) ans += i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll K;
    cin >> K;
    queue<ll> que;
    rep(1, i, 10)
    {
        que.push(i);
    }
    rep(0, i, K)
    {
        if (i == K - 1)
        {
            cout << que.front() << endl;
            return 0;
        }
        ll a = que.front();
        ll b = a % 10;
        que.pop();
        // 末尾の数字が0でないとき
        if (a % 10 != 0)
        {
            que.push(10 * a + b - 1);
        }
        que.push(10 * a + b);
        // 末尾の数字が9でないとき
        if (a % 10 != 9)
        {
            que.push(10 * a + b + 1);
        }
    }
}


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

#define db(x) cerr << #x << " == " << x << endl
#define all(container) container.begin(), container.end()
#define mp(i,j) make_pair(i,j)
#define pb push_back

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vii;

template<typename T>
void print_vector_debug(const T& t) {
	cout << "[DEBUG] VECTOR:";
	for (auto i = t.cbegin(); i != t.cend(); ++i) {
		if ((i + 1) != t.cend()) {
			cout << *i << " ";
		} else {
			cout << *i << endl;
		}
	}
}

const int MAXN = 1e5 + 5;

int N;
int vals[MAXN];
int dp[MAXN];
int vis[MAXN];

int solve(int idx)
{
	if (idx == N - 1)
	{
		return 0;
	}
	
	if (idx >= N)
	{
		return 9999999;
	}
	
	if (vis[idx])
	{
		return dp[idx];
	}
	vis[idx] = 1;

	int res = min(solve(idx + 1) + abs(vals[idx] - vals[idx + 1]), solve(idx + 2) + abs(vals[idx] - vals[idx + 2]));
	dp[idx] = res;
	
	return res;
}

int main() 
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &vals[i]);
		
	}
	
	printf("%d\n", solve(0));
	return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>

int main (void){

        int n, i,j;
        char cryp[101];
        int key[100];
        char c;

        while(1){
                scanf("%d",&n);
                        if(n == 0)
                                break;

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

                for(i = 0; cryp[i]; i++){
                        c = cryp[i];
                        for(j = 0; j < key[i%n]; j++){
                                if(c == 'a')
                                        c = 'Z';
                                else if(c == 'A')
                                        c = 'z';
                                else
                                        c -= 1;
                        }
                        printf("%c",c);
                }
                puts("");
        }

        return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep2(i, j, n) for (int i = j; i <= (int)(n); i++)
// greedy
int main(void){
    ll N;
    cin >> N;
    ll A[87];
    ll money = 1000;
    for(int i = 1; i <= N; i++) cin >> A[i];
    for(int i = 1; i <= N-1 ;i++){
        ll stock = 0;
        if(A[i] < A[i+1]){
            stock = money / A[i];
        }
        money += (A[i+1] - A[i]) * stock;
    }
    cout << money << endl;
}

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

using ll = long long;

const int N = 3e3L + 11;

int s[N];

int main() {
	ios :: sync_with_stdio(false);
	int n, m, k; cin >> n >> m >> k;
	ll a, b, c; cin >> a >> b >> c;
	ll t; cin >> t;
	for(int i = 1; i <= m; i ++)
		cin >> s[i];
	s[m + 1] = n + 1;
	int ans = -1;
	vector <int> v(N, 0);
	for(int i = 1; i <= m; i ++)
		if((s[i] - 1) * b <= t) {
			ans ++;
			int x = s[i + 1] - s[i] - 1;
			ll r = (t - (s[i] - 1) * b) / a;
			if(r >= x)
				ans += x;
			else {
				ans += r;
				for(int _ = 0; _ < N && r < x; _ ++) {
					ll nt = t - (s[i] - 1) * b - (r + 1) * c;
					if(nt >= 0) {
						v.push_back(min(nt / a + 1, x - r));
						r += nt / a + 1;
					} else
						break;
				}
			}
		}
	sort(v.begin(), v.end(), greater<int>());
	for(int i = 0; i < k - m; i ++)
		ans += v[i];
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 27120
//
//  main.cpp
//  ABC121
//
//  Created by hiroaki on 2019/03/15.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n,m,c;
    cin>>n>>m>>c;
    vector<vector<int>> A;
    vector<int> B(m);
    for (int i=0; i<m; i++) {
        cin>>B.at(i);
    }
    for (int i=0; i<n; i++) {
         vector<int> v(m);
        for (int j=0; j<m; j++) {
            cin >> v.at(j);
        }
        A.push_back(v);
    }
    int success = 0;
    for (int i=0; i<n; i++) {
        int sum =0;
        for (int j=0; j<m; j++) {
            sum +=A[i][j]*B[j];
        }
        if (sum+c>0) {
            success++;
        }
    }
    cout<<success<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <map>
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <iterator>
#include <array>
typedef long long int ll;
using namespace std;
#define maxN 200005
#define mod 1000000007

int n;
ll all[maxN] = {};

void solve()
{
    ll ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> all[i];
    }
    map<ll, ll> m;
    for (int i = 0; i < n; i++)
    {
        if (m[i - all[i]])
        {
            ans += m[i - all[i]];
        }
        m[i + all[i]]++;
    }
    cout << ans << endl;
}

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

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

using namespace std;

int main(){
	int n, k, q, ans;
	scanf("%d %d %d", &n, &k, &q);
	int a[n];
	memset (a,0,n*sizeof(int));
	for (int i = 0; i < q; i++){
		scanf("%d", &ans);
		a[ans-1]++;
	}

	for (int i = 0; i < n; ++i){
		if((q-a[i]) < k){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}



Measured memory_bytes: 1024
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, a);
    IN(ll, b);
    string A, B;
    REP(i, b)
    {
        A.push_back('0' + a);
    }
    REP(i, a)
    {
        B.push_back('0' + b);
    }
    OUT(min(A, B));
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
	int n; std::cin >> n;
	for (int i=0; i<n; i++) {
		int s, t;
		std::cin >> s >> t;
		std::cout << s;
		if (0 <= s && s <= 5) {
			if (0 <= t && t <= 5) {
				if (s<t) {
					for (int k=s+1; k<=t; k++) std::cout << " " << k;
				} else {
					for (int k=s-1; k>=t; k--) std::cout << " " << k;
				}
			}
			else { // t = 6,7,8,9
				for (int k=s+1; k<=t; k++) std::cout << " " << k;
				//for (int k=s+1; k<=5; k++) std::cout << " " << k;
				//if (t<=7) {
				//	for (int k=6; k<=t; k++) std::cout << " " << k;
				//} else {
				//	for (int k=9; k>=t; k--) std::cout << " " << k;
				//}
			}
		}
		else { // s = 6,7,8,9
			if (0 <= t && t <= 5) {
				//if (s <= 7) {
				//	for (int k=s-1; k>=t; k--) std::cout << " " << k;
				//} else {
					for (int k=s+1; k<=9; k++) std::cout << " " << k;
					for (int k=5; k>=t; k--) std::cout << " " << k;
				//}
			}
			else { // t = 6,7,8,9
				if (s<t) {
					for (int k=s+1; k<=t; k++) std::cout << " " << k;
				} else {
				//	for (int k=s-1; k>=t; k--) std::cout << " " << k;
					for (int k=s+1; k<=9; k++) std::cout << " " << k;
					for (int k=5; k>=0; k--) std::cout << " " << k;
					for (int k=1; k<=5; k++) std::cout << " " << k;
					for (int k=6; k<=t; k++) std::cout << " " << k;
				}
				
			}
		}
		std::cout << std::endl;
	}
	
	return 0;
}




Measured memory_bytes: 3072
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  cout << (1000 - n % 1000) % 1000 << endl;
}

Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2010;
int n,m;
int h[N],sta[N];
bool mp[N][N];
char s[N][N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf("%s",s[i]+1);
	for (int i=1;i<n;++i)
		for (int j=1;j<m;++j)
		mp[i][j]=(s[i][j]^s[i][j+1]^s[i+1][j]^s[i+1][j+1])==0 ? 1:0;
	int ans=max(n,m);
	for (int i=1;i<n;++i){
		for (int j=1;j<m;++j) h[j]=(h[j]+1)*mp[i][j];
		int top=0;
		for (int j=1;j<=m;++j){
			while (top&&h[sta[top]]>=h[j]){
				ans=max(ans,(h[sta[top]]+1)*(j-sta[top-1]));
				--top;
			}
			sta[++top]=j;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 8192
import sys
 
n = int(input())
As = list(map(int, input().split()))

if 0 in As:
  print(0)
  sys.exit()

ans = 1
for i in range(n):
  ans = ans*As[i]
  if ans > 10**18:
    print(-1)
    sys.exit()
 
print(ans)

Measured memory_bytes: 21552
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr ll MOD = 1e9+7;

inline void md(ll & a, ll & b) { a = (a + b) % MOD; }

bitset<303> valid[303][303];
ll dp[303][303][303];
vector<ii> C[303];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);

	int N, M; cin >> N >> M;
	for (int i = 0, l, r, x; i < M; ++i) {
		cin >> l >> r >> x; C[r].emplace_back(l, x);		
	}

	for (int r = 0; r <= N; ++r) for (int g = 0; g <= N; ++g) for (int b = 0; b <= N; ++b) {
		valid[r][g][b] = 1;
		int m = max({ r, g, b });
		for (auto & p : C[m]) {
			if ((p.f <= r || m == r) + (p.f <= g || m == g) + (p.f <= b || m == b) != p.s) valid[r][g][b] = 0;
		}
	}

	dp[0][0][0] = 1;
	for (int r = 0; r <= N; ++r) for (int g = 0; g <= N; ++g) for (int b = 0; b <= N; ++b) {
		if (!valid[r][g][b]) continue;
		int m = max({ r, g, b });
		md(dp[m + 1][g][b], dp[r][g][b]), md(dp[r][m + 1][b], dp[r][g][b]), md(dp[r][g][m + 1], dp[r][g][b]);
	}

	ll ans = 0;
	for (int r = 0; r <= N; ++r) for (int g = 0; g <= N; ++g) for (int b = 0; b <= N; ++b)
		if ((r == N || g == N || b == N) && valid[r][g][b]) md(ans, dp[r][g][b]);
	cout << ans;
}

Measured memory_bytes: 223744
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    string S; cin>>S;
    int cnt=0;

    for (int i = 0; i < S.length(); ++i) {
        if(S[i]=='+') cnt++;
        else cnt--;
    }
    cout<<cnt<<endl;

    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int size = Integer.parseInt(scanner.next());
        int[] array = new int[size];
        for (int i = 0; i < size; i++) {
            array[i] = Integer.parseInt(scanner.next());
        }

        boolean flag = true;
        int swapCount = 0;
        while (flag) {
            flag = false;
            for (int j = size - 1; j > 0; j--) {
                if (array[j] < array[j - 1]) {
                    swap(j, j - 1, array);
                    swapCount++;
                    flag = true;
                }
            }
        }
        System.out.println(concat(array));
        System.out.println(swapCount);
    }

    private static String concat(int[] array) {
        StringJoiner joiner = new StringJoiner(" ");
        for (int value : array) {
            joiner.add(String.valueOf(value));
        }
        return joiner.toString();
    }

    private static void swap(int i, int j, int[] array) {
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
}

Measured memory_bytes: 26216
N_A_B = map(str,input().split(" "))
list_NAB = list(map(int,N_A_B))
N = list_NAB[0]
A = list_NAB[1]
B = list_NAB[2]


box = []
for i in range(N+1):
	l = [int(j) for j in list(str(i))]
	m = sum(l)

	if A <= m <= B:
		box.append(i)
		sum__ = sum(box)
print(sum__)


Measured memory_bytes: 3296
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
#include <list>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

const int N = 2010;
const int MOD = 1e9+7;
int L[N][N];
int R[N][N];
int U[N][N];
int D[N][N];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    rep(i,n){
        ans+=a[i];
    }
    sort(a.begin(),a.end());
    vector<pair<ll,ll> > bc(m);
    rep(i,m){
        cin>>bc[i].second>>bc[i].first;
    }
    sort(bc.begin(), bc.end());
    reverse(bc.begin(), bc.end());
    int idx=0;
    rep(i,m){
        rep(j,bc[i].second){
            if(bc[i].first>a[idx] && idx<n){
                ans-=a[idx++];
                // a.push_back(bc[i].first);
                ans+=bc[i].first;
            }else break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	double a, b, C;
	cin >> a >> b >> C;

	double S = a * b * sin(C / 180 * PI) / 2;
	double L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(C / 180 * PI));
	double h = 2 * S / a;

	printf("%.10f\n%.10f\n%.10f\n", S, L, h);

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
public class Main {

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		String[] str = x.split(" ");
		ArrayList <Integer> result = new ArrayList<Integer>();
		for(int i = 0; i < str.length; i++){
			result.add(Integer.parseInt(str[i]));
		}
		Arrays.sort(str);
		System.out.println(str[0]+" "+str[1]+" "+str[2]);
	}
}

Measured memory_bytes: 24332
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int a[3];
    while(cin>>a[0]>>a[1]>>a[2]){
        sort(a,a+3);
        if(a[0]==a[1]&&a[1]==a[2])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();
		sc.close();
		double a = (double)D/S;
		System.out.println(a<=T?"Yes":"No");
	}

}

Measured memory_bytes: 35796
a=gets.chomp.chars
b=a.size

c=[]
d=[]
e=''
count=0
if b%2 == 0
  #偶数の処理
  f=b/2
  f.times do |ff|
    c << a[ff]
    d << a[b-ff-1]
    if c[ff] != d[ff]
      d[ff] = c[ff]
      count += 1
    end
  end
else
  #奇数(真ん中除く)処理
  f=b/2
  m=f+1
  b-=1
  a.delete_at(m-1)
  f.times do |ff|
    c << a[ff]
    d << a[b-ff-1]
    if c[ff] != d[ff]
      d[ff] = c[ff]
      count += 1
    end
  end
end

puts count

Measured memory_bytes: 1788
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    h,w=INTM()
    ans=['#'*(w+2)]
    
    for i in range(h):
        temp=STR()
        temp='#'+temp+'#'
        #print(ans)
        ans.append(temp)
    ans.append(['#'*(w+2)])
    for i in range(h+2):
        print(*ans[i],sep='')
if __name__ == '__main__':
    do()

Measured memory_bytes: 4468
import sys
from fractions import gcd
def prime_factorize_2(n):
    res = set()
    div = 2
    if n % 2 == 0:
        while n % div == 0:
            n //= div
        res.add(div)
    div += 1
    while div ** 2 <= n:
        if n % div == 0:
            n //= div
            res.add(div)
        else:
            div += 2
    if n != 1:
        res.add(n)
    return res

def main(a, b):
    #a, b = [int(i) for i in sys.stdin.readline().split()]
    _gcd = gcd(a,b)
    #memo_ls = [0 for i in range(_gcd)]
    #memo_set = set()
    cnt = 0
    if _gcd == 1:
        print(1)
    else:
        res = prime_factorize_2(_gcd)
        print(len(res) + 1)
if __name__ == "__main__":
    a, b = [int(i) for i in sys.stdin.readline().split()]
    main(a, b)

Measured memory_bytes: 64236
/*
oruegg19 - Arundhati Bhattacharya
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<unsigned ll>
#define mp make_pair
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const unsigned ll l=1000000007;
const int MAX_=2000;
int T;

void solve(int t)
{
  int n,k;
  cin >> n >> k;
  vii a(n), b(n);
  for(int i=0; i<n; i++)
  {
    cin >> a[i];
  }

  // b[1] = abs( a[0]-a[1] );

  for(int i=1; i<n; i++)
  {
    b[i] = INT_MAX;

    for(int j=1; i-j >= 0 && j <= k; j++)
    {
      b[i] = min(b[i], b[i-j] + abs(a[i-j] - a[i]));
    }
  }

  cout << b[n-1] << endl;
}

int main()
{
  IOS
  int t,testCases;
  testCases=1;

  while(testCases--)
  {
    t=1;
    // cin >> t; //comment this in case of singular test case
    T = t;
    while(t--)
    {
      // cout << "HERE" << endl;
      solve(t);
    }
  }
  return 0;

}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}

template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main()
{
    fast();
    ll n,d;
    cin>>n>>d;
    d*=d;
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        if(d>=(x)*x+y*y)
            ans++;
    }
    cout<<ans<<nl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
string s[10],st[10],add[10][10];
int sz[10][10];
bool iran[10];
int main(){
	while(true){
		int n;
		cin>>n;
		if(n==0) break;
		rep(i,n) iran[i]=0;
		rep(i,n) cin>>s[i];
		rep(i,n){
			rep(j,n){
				if(i==j) continue;
				string x=s[i],y=s[j];
				if(x==y){
					iran[min(i,j)]=true;
					continue;
				}
				if(x.size()>y.size()) continue;
				int xs=x.size(),ys=y.size();
				rep(k,ys-xs+1) if(x==y.substr(k,xs)) iran[i]=true;
			}
		}
		int it=0;
		rep(i,n) if(!iran[i]) st[it]=s[i],it++;
		n=it;
		int a[10];
		rep(i,n) a[i]=i;
		string mn;
		rep(i,n) rep(j,n){
			if(i==j) continue;
			string x=st[i],y=st[j];
			int xs=x.size(),ys=y.size(),mx=min(xs,ys);
			bool ok=0;
			for(int m=mx;m>0;m--){
				if(x.substr(xs-m,m)==y.substr(0,m)){
					add[i][j]=y.substr(m,ys-m);
					ok=true;
					break;
				}
			}
			if(!ok) add[i][j]=y;
			sz[i][j]=add[i][j].size();
		}
		int ms=1000000;
		do{
			int sum=st[a[0]].size();
			rep(i,n-1) sum+=sz[a[i]][a[i+1]];
			if(sum>ms) continue;
			string now=st[a[0]];
			rep(i,n-1) now+=add[a[i]][a[i+1]];
			if(sum<ms) mn=now,ms=sum;
			else if(now<mn) mn=now;
		}while(next_permutation(a,a+n));
		cout << mn << endl;
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#include<stdio.h>
#include<iostream>
#include<utility>
using namespace std;
long long x,n,a[100002][102],c,s,ok,b;
pair<long long,long long>p[102];
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
    cin >> n >> x;
    for(int i=0;i<n;i++){
    	cin >> c >> b;
    	ok = ok + b;
    	p[i]=make_pair(b,c);
    }
    long long inf=0x7fffffffff; //cout << inf;
	for(int i=1;i<ok+1;i++) for(int j=0;j<n;j++) a[i][j]=inf;
	a[p[0].first][0]=p[0].second;	    
//	for (int i=0;i<n;i++){for(int j=0;j<=ok;j++) cout << a[j][i] << " "; cout << endl;}
//	cout << endl << endl;
	for(int i=0;i<ok+1;i++){
		for(int j=1;j<n;j++){
			if(p[j].first <= i) a[i][j]=min(p[j].second+a[i-p[j].first][j-1], a[i][j-1]);
		    else a[i][j]=a[i][j-1];
		}
	}
//	for (int i=0;i<n;i++){for(int j=0;j<=ok;j++) cout << a[j][i] << " "; cout << endl;}
	s = ok;
	while(a[s][n-1]>x) s--;
	cout << s;
return 0;
}

Measured memory_bytes: 80000
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	set<int>iset;
	cin>>a;
	for(int i=0;i<a;i++)
	{
		cin>>b;
		iset.insert(b);
	}
	cout<<iset.size();
	return 0;
}

Measured memory_bytes: 256
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

x1, y1, x2, y2 = lr()
diff1 = x2 - x1
diff2 = y2 - y1
x3, y3 = x2 - diff2, y2 + diff1
x4, y4 = x1 - diff2, y1 + diff1
print(x3, y3, x4, y4)


Measured memory_bytes: 3060