akhauriyash/Code-Regression huggingface dataset:
//https://atcoder.jp/contests/abc158/tasks/abc158_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in");
    //std::ifstream in("./input.txt");
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N,A,B; cin>>N>>A>>B;
    ll tmp=A+B;
    ll n=N/tmp;    
    N-=n*tmp;
    ll ans=min(N,A);
    ans+=n*A;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int d, n; cin >> d >> n;
    
    if(d > 0){
        if(n == 100){
            cout << fixed << int(pow(100,d) * n + pow(100,d));
        }else{
            cout << fixed << int(pow(100,d) * n);
        }
    }else{
        if(n == 100){
            cout << n + 1;
        }else{
            cout << n;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>

typedef long long int ll;


using namespace std;

vector<int>p(50010,1);
int n;

void calc(){
	for(int i=0; i<50010; i++){
		if(i<2)p[i]=0;
		else{
			for(int j=2; j<=sqrt(i); j++){
				if(i%j==0){
					p[i]=0;
					break;
				}
			}
		}
	}
}

int f(){
	int a=0;
	for(int i=0; i<=n/2; i++){
		if(p[i]&&p[n-i])a++;
	}
	return a;
}

int main(){
	calc();
	while(1){
		cin>>n;
		if(n==0)break;
		cout<<f()<<endl;
	}
}

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

#pragma GCC optimze("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()

#define ll long long
#define int long long
#define ld long double

const int N = 3e6 + 10;

const int M = 1e9 + 7;

int fact[N];

int pw(int a, int n) {
    int res = 1;
    while (n>0) {
        if (n & 1) {
            res *= a;
            res %= M;
            n--;
        }else {
            a *= a;
            a %= M;
            n >>= 1;
        }
    }
    return res;
}

int inv(int a) {
    return pw(a, M - 2);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    int z = x + y;
    if (z % 3 != 0) {
        cout << "0\n";
        return 0;
    }
    int c = z / 3;
    x -= c;
    y -= c;
    if (x < 0 || y < 0 || x + y > c) {
        cout << "0\n";
        return 0;
    }
    //cout << x << " " << y << '\n';
    fact[0] = 1;
    for (int i = 1; i < N; i++) fact[i] = (fact[i - 1] * i) % M;
    cout << (((((fact[c] * inv(fact[x + y])) % M * inv(fact[c - x - y])) % M * fact[x + y]) % M * inv(fact[x])) % M * inv(fact[y])) % M << '\n';
    return 0;
}


Measured memory_bytes: 23680
n, m = map(int, input().split())
arr = [0]*n
for i in range(m):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    arr[l] += 1
    if r == n - 1:
        continue
    arr[r+1] -= 1
csum = [0]*n
csum[0] = arr[0]
for i in range(1,n):
    csum[i] += csum[i-1] + arr[i]
print(csum.count(m))

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

int main(void)
{
    int n;
    cin >> n;
    int d[n];
    for ( int i = 0; i < n; i++ )
        cin >> d[i];
    
    sort(d, d + n);
    
    int ans = n;
    for ( int i = 1; i < n; i++ )
        if ( d[i] == d[i-1] )
            ans--;
    
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include <vector>

using namespace std;



int main() {
	string n;
	string seven = "No";
	cin >> n;

	for (int i = 0; i < 3; i++) {
		if (n[i] == '7') {
			seven = "Yes";
		}
	}

		cout << seven;
}


Measured memory_bytes: 3132
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import static java.util.Collections.sort;

/**
 */
class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		System.out.println(String.format("%.0f",fact(n)));
	}

	public static double fact(int n) {
		double ans = 1;
		for(int i=2;i<=n;i++) {
			ans *= i;
		}
		return ans;
	}
}

Measured memory_bytes: 26200
s = input()
t = input()

count = 0
reg = 0

for i in range(len(s)-len(t)+1):
  for j in range(len(t)):
    if s[i+j] == t[j]:
      count = count + 1
  if count > reg:
    reg = count
  count = 0

reg = len(t) - reg
print(reg)
  


Measured memory_bytes: 9092
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
string to_str(ll A){
    stringstream ss;
    ss << A;
    return ss.str();
}
ll func(int a){
    string S = to_str(a);
    int ans = 0;
    for(auto c:S){
        ans += c - '0';
    }
    return ans;
}
main(){
    int N;
    cin >> N;
    ll mini = INF;
    rep(i,N){
        if(i == 0)continue;
        mini = min(mini, func(i) + func(N-i));
        //cout << mini << endl;
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL __int128
#define ll long long
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d%d", &a, &b)
#define sc3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define scl(a) scanf("%lld", &a)
#define scl2(a, b) scanf("%lld%lld", &a, &b)
#define ss(a) scanf("%s", a)
#define mem(a, b) memset(a, b, sizeof(a))
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PII pair<int, int>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int a[maxn], b[maxn];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> a[i];
    for(int i = 1; i <= n; i ++) cin >> b[i];
    reverse(b + 1, b + n + 1);
    bool ok = false;
    for(int i = 1; i <= n; i ++){
        if(a[i] != b[i]) continue;
        bool f = false;
        for(int j = 1; j <= n; j ++){
            if(a[i] != b[j] && a[j] != b[i]){
                f = true;
                swap(b[i], b[j]);
                break;
            }
        }
        if(!f){
           cout << "No" << endl;
           return 0;
        }
    }

        cout << "Yes" << endl;
        for(int i = 1; i <= n; i ++){
            if(i != 1)cout << " ";
            cout << b[i];
        }
        cout << endl;
    return 0;
}


Measured memory_bytes: 5180
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN = 222;
int l[MAXN];
int main()
{
        // freopen("../in.txt","r",stdin);
        // freopen("../out.txt","w",stdout);
        int n,x;
        while(cin>>n>>x)
        {
                int sum = 0;
                int cnt = 0;
                for(int i=0;i<n;++i)
                {
                        cin>>l[i];

                        if(sum<=x)      cnt++;
                        sum += l[i];
                }
                if(sum<=x)      cnt++;
                cout<<cnt<<endl;

        }
        return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n, p;
	string s;
	cin >> n;
	map<string, vector<P>> rest;
	for(int i = 0; i < n; ++i)
	{
		cin >> s >> p;
		rest[s].emplace_back(P(p, i + 1));
	}
	for(const auto& r : rest)
	{
		auto vec = r.second;
		sort(vec.begin(), vec.end());
		for(auto it = vec.rbegin(); it != vec.rend(); ++it)
		{
			cout << it->second << endl;
		}
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const ll maxn=1e5+5;
ll n,a[maxn],pre[maxn],suf[maxn],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)pre[i]=__gcd(pre[i-1],a[i]);
	for(int i=n;i>=1;i--)suf[i]=__gcd(suf[i+1],a[i]);
	for(int i=1;i<=n;i++)ans=max(ans,__gcd(pre[i-1],suf[i+1]));
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
string s,w,ans="";
int main()
{
	int r; 
    cin>>s>>w;
    if(s.size()<w.size())
	{
        cout<<"UNRESTORABLE";
        return 0;
    }
    for(int i=0;i<=s.size()-w.size();i++)
	{
        int k=i;
        string cs=s;
        int j=0;
        while(j<w.size())
		{
            if(cs[k]=='?')
                cs[k]=w[j];
            else if(s[k]!=w[j])
                break;
            k++;
            j++;
        }
        if(j==w.size())
		{
		   for(r=0;r<cs.size();r++)
		   {
                if(cs[r]=='?')
                    cs[r]='a';
            }
            if(ans=="")
                ans=cs;
            else ans=min(ans,cs);
        }
    }
    if(ans=="")
        cout<<"UNRESTORABLE";
    else 
	cout<<ans;
    return 0;
}

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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

int main(){
    int n; cin >> n;
    int dp[n+1][3]={0};
    //vector<vector<int>> dp(n+1,vector<int>(3));
    rep(i,3) dp[0][i]=0;
    vector<vector<int>> h(n,vector<int>(3));
    rep(i,n){rep(j,3){cin >> h[i][j];}}

    rep(i,n){
        rep(j,3){
            rep(k,3){
                if(j==k) continue;
                chmax(dp[i+1][k],dp[i][j]+h[i][k]);
            }
        }
    }

    int ans=0;
    rep(i,3) chmax(ans,dp[n][i]);
    cout << ans << endl;
}

Measured memory_bytes: 6912
#include<stdio.h>
  int H;
void maxHeapify(long *A,long i){
  long B[10];
  long left,right,largest;
    left = 2*i;
    right = 2*i+1;
    
    if(left <= H && A[left] > A[i]){
      largest = left;
    }
    else{
      largest = i;
    }
    if(right <= H && A[right] > A[largest]){
      largest = right;
    }
    if(largest != i){
      B[0] = A[i];
      A[i] = A[largest];
      A[largest] = B[0];
      maxHeapify(A,largest);
  }
}
int main(){
  long A[500000];
  long i;
  scanf("%d",&H);

  for(i = 1;i <= H;i++){
    scanf("%ld",&A[i]);
  }
  for(i = H/2;i >= 1;i--){
    maxHeapify(A,i);
  }
  for(i = 1;i <= H;i++){
    printf(" %ld",A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 5636
def main():
    n = int(input())
    p = [int(a) for a in input().split()]

    ans = 0
    for i in range(n-2):
        if (p[i] < p[i+1] < p[i+2]):
            ans += 1
        if (p[i] > p[i+1] > p[i+2]):
            ans += 1
    print(ans)

main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld h, w, k;
  cin >> h >> w >> k;
  cin.ignore(1);
  vector<vector<char>> b(h, vector<char>(w));
  for (lld y = 0; y < h; y++) {
    for (lld x = 0; x < w; x++) {
      cin >> b[y][x];
    }
    cin.ignore(1);
  }
  lld c = 0;
  for (lld i = 0; i < 1 << h; i++) {
    for (lld j = 0; j < 1 << w; j++) {
      lld s = 0;
      for (lld y = 0; y < h; y++) {
        for (lld x = 0; x < w; x++) {
          if (b[y][x] == '#' && ((1 << x) & j) == 0 && ((1 << y) & i) == 0) {
            s++;
          }
        }
      }
      if (s == k) {
        c++;
      }
    }
  }
  cout << c << "\n";
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define per(i,m,n) for(lli i=m-1;i>=n;i--)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  a+=b;
  if(a>24)a%=24;
  if(a==24)a=0;
  cout<<a<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  divisors.sort()
  return divisors
  
f_list = make_divisors(n)

k = len(f_list)
for i in range(-(-k//2)):
  t = f_list[i]+f_list[k-i-1]

print(t - 2)

Measured memory_bytes: 3264
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }
 
   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

struct edge{int u,v,cost;};
bool comp(const edge& e1, const edge& e2){
  return e1.cost<e2.cost;
}
edge es[200010];
int V,E;
vector<pint> x,y;

int kruskal(){
  sort(es, es+E, comp);
  UnionFind uf(V);
  int res=0;
  for(int i=0;i<E;i++){
    edge e=es[i];
    if(!uf.same(e.u, e.v)){
      uf.unite(e.u, e.v);
      res+=e.cost;
    }
  }
  return res;
}

int main(){
  cin >> V;
  E=2*V-2;
  rep(i,V){
    int a,b;
    cin >> a >> b;
    x.push_back(pint(a,i));
    y.push_back(pint(b,i));
  }
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  rep(i,V-1){
    es[2*i]=(edge){x[i].second,x[i+1].second,x[i+1].first-x[i].first};
    es[2*i+1]=(edge){y[i].second,y[i+1].second,y[i+1].first-y[i].first};
  }
  int ans=kruskal();
  cout << ans << endl;
return 0;}


Measured memory_bytes: 4588
#include <bits/stdc++.h>
using namespace std;
    
#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
    
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
    
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
    
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

LL memo[2019];
int main(){
    string S;
    cin >> S;

    reverse(ALL(S));
    memo[0] = 1;
    LL ans = 0;

    LL now = 0;
    LL tmp = 1;
    LL MOD = 2019;
    REP(i, S.size()) {
        now += (S[i] - '0') * tmp;
        now %= MOD;

        tmp *= 10;
        tmp %= MOD;

        ans += memo[now];
        memo[now]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3768
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(' ').map { it.toInt() }
    val ax = Math.abs(x)
    val ay = Math.abs(y)
    if (ax == ay) {
        // 絶対値が同じなので、符号を揃えたい
        if (x == y) println(0)
        else println(1)
    } else if (ax < ay) {
        // yの絶対値が大きいので、xの絶対値を増やしたい
        var ans = ay - ax
        if (x < 0) ans += 1 // ｘが-だったら最初に+にする
        if (y < 0) ans += 1 // ｙが-だったら最後に-にする
        println(ans)
    } else {
        // yの絶対値が小さいので、xの絶対値を減らしたい
        var ans = ax - ay
        if (x > 0) ans += 1 // ｘが+だったら最初に-にする（xの絶対値が大きい時、0はあり得ない）
        if (y > 0) ans += 1 // ｙが+だったら最後に-にする（0のときは反転しない）
        println(ans)
    }
}


Measured memory_bytes: 36304
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;
  const int N=2e5+2;

  int32_t main()
  {
    #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif
       IOS
       //Rally C atcoder
       int n,x,l=INT_MAX,r=0;
       cin>>n;
       vector<int> v(n);
       for(int i = 0;i<n;i++)
       {
        cin>>v[i];
        l = min(l,v[i]);
        r = max(r,v[i]);
       }
       int ans = INT_MAX;
       for(int i = l;i<=r;i++)
       {
            int sum=0;
            for(int j=0;j<n;j++)
            {
                sum+=(v[j]-i)*(v[j]-i);
            }
            ans=min(ans,sum);
       }
       cout<<ans;
       return 0;
    }

Measured memory_bytes: 3580
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    l = int(input())
    x = (l/3)
    print(x**3)
    return

#Solve
if __name__ == "__main__":
    solve()

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

using namespace std;

#define PI acos(-1)

struct Point {
	double x, y;
};

void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;
	double th = 60 * PI / 180;
	s.x = (2 * a.x + b.x) / 3; s.y = (2 * a.y + b.y) / 3;
	t.x = (a.x + 2 * b.x) / 3; t.y = (a.y + 2 * b.y) / 3;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
	koch(n - 1, a, s);
	printf("%.10f %.10f\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.10f %.10f\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.10f %.10f\n", t.x, t.y);
	koch(n - 1, t, b);
}

int main() {
	int n; cin >> n;
	Point a = { 0,0 }, b = { 100,0 };

	printf("%.10f %.10f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.10f %.10f\n", b.x, b.y);

	return 0;
}


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

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; }

using ll = long long;

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

int main() {
  int N;
  cin>>N;
  vector<ll> v(N);
  for(int i = 0; i < N; i++) {
    int x;
    cin>>x;
    v[i]=-x;
  }
  vector<ll> ans;
  for(int i = 0; i < N;i++) {
    auto ite=upper_bound(ans.begin(),ans.end(),v[i]);
    if(ite==ans.end()) ans.push_back(v[i]);
    else *ite=v[i];
  }
  cout<<ans.size()<<endl;
}

Measured memory_bytes: 2168
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin>>n>>k;
    double ans=0;
    for(int i=1;i<=n;i++){
        double r=i,p=1;
        while(r<k){
            r*=2;
            p/=2.0;
        }
        ans+=p/n;
    }
    printf("%.15f\n",ans);
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main(){
	int n,a[100] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (n>-1; n--;){

		if (n == 0){
			cout << a[n];
		}

		if (n != 0){
			cout << a[n] << " ";
		}

	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
using namespace         std;
#define                 int long long
#define                 double long double
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<'\n'
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 1014159
#define  vi vector<int>
#define  v  vector
#define die exit(0)
#define alln(arr) arr+1 , arr+1+n
using namespace __gnu_pbds;  
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update> oset; 

int n,arr[N];

void solve()
{
    
    char a;
    cin>>a;
    a++;
    cout<<a;
}


signed main() 
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int t = 1;
    //cin>>t;
    forn(i,1,t)
    {
        solve();
        nl;
    }



    return 0;

}

//       clang++ c.cpp ; ./a.out < a.txt ;  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double EPS = 1e-8;

ll modNorm(ll a, ll m) {
  return (a%m+m)%m;
}

// ax+by=gcd(a,b)
ll extgcd(ll a, ll b, ll &x, ll &y) {
  ll g = a;
  x = 1; y = 0;
  if (b) {
    g = extgcd(b, a%b, y, x);
    y -= (a/b) * x;
  }
  return g;
}

ll invMod(ll a, ll p) {
  ll x, y;
  if (extgcd(a,p,x,y) == 1) return (x+p)%p;
  return 0;
}

typedef vector<bool> vec;
typedef vector<vec> mat;

ostream &operator<<(ostream &os, const vec &a) {
  FOR(it, a) os << *it << " ";
  return os;
}
ostream &operator<<(ostream &os, const mat &a) {
  FOR(it, a) os << *it << endl;
  return os;
}


bool gauss_jordan_cong(const mat &A, const vec &b, int m, vec &x) {
  int n = A.size();
  mat B(n, vec(n+1));
  REP(i,n) REP(j,n)
    B[i][j] = A[i][j];
  REP(i, n) B[i][n] = b[i];

  //cout << B << endl;
  int rank = 0;
  int nowy = 0;
  REP(x, n) {
    int pivot = nowy;
    for (int j=nowy+1; j<n; ++j)
      if (B[j][x]) pivot = j;
    swap(B[nowy], B[pivot]);
    // ツ嘉ーツつェツづ按つ「ツつゥツ、ツ暗ェツ暗督づづ按つ「
    if (!B[nowy][x]) {
      continue;
    }
    
    for (int j=nowy+1; j<n; ++j) {
      if (B[j][x])
        for (int k=x; k<=n; ++k) B[j][k] = B[j][k] ^ B[nowy][k];
    }
    nowy++;
    
    //cout << B << endl;
  }
  //cout << B << endl;
  for (int y=nowy; y<n; ++y)
    if (B[y][n])
      return 0;
  return 1;
}

int main() {
  int m, n, d;
  int c = 0;
  while(cin>>m>>n>>d, m||n||d) {
    bool ba[n][m];
    mat A(n*m, vec(n*m));
    vec b(n*m);
    REP(i,n) {
      REP(j,m) {
        cin >> ba[i][j];
        A[i*m+j][i*m+j] = 1;
        REP(k,n) {
          REP(l,m) {
            int dis = abs(i-k)+abs(j-l);
            if (dis == d) {
              A[i*m+j][k*m+l] = 1;
            }
          }
        }
        b[i*m+j] = ba[i][j];
      }
    }
    vec x;
    cout << gauss_jordan_cong(A,b,2,x) << endl;
    
  }
}

Measured memory_bytes: 1044
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll LINF = 1001002003004005006LL;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll x; cin >> x;
    for (ll i = -1000; i<1000; ++i) {
        for (ll j = -1000; j<1000; ++j) {
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if ((a-b)==x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


















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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    double ans = v[0];
    for (int i = 1;i < n;i++) ans = (ans+v[i])/2;
    printf("%lf\n",ans);
}

Measured memory_bytes: 3728
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;

	int ans = 0;
	for(int i=1; i<=(b-a); i++){
		ans += i;
	}
	ans -= b;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int N;
    cin >> N;
    long A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A, A + N);
    long ans = 0;
    for(int i = 0; i < N; i++){
        ans += abs(A[N / 2] - A[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define M_PIl   3.141592653589793238462643383279502884L

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin>>n;
    ll a[n];
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[i]-=i+1;
    }
    
    sort(a,a+n);
    
    ll b1,b2,sum1=0,sum2=0;
    bool even;
    if(n%2!=0){
        b1 = a[n/2];
        even = false;
    }else{
        b1 = a[n/2];
        b2 = a[n/2-1];
        even = true;
    }
    
    
    for(int i=0;i<n;i++){
        sum1+=abs(a[i]-b1);
        if(even){
            sum2+=abs(a[i]-b2);
        }
    }
    
    if(even){
        cout<<min(sum1,sum2)<<"\n";
    }else{
        cout<<sum1<<"\n";
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LL long long
#define dl double
template <class T>
void rd(T &x){
  x=0;T f=1;char ch=getchar();
  while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
  while(ch<='9' && ch>='0')x=x*10+ch-'0',ch=getchar();x*=f;
}
using namespace std;
int L,R,d,cnt;
int main(){
 // freopen("in.txt","r",stdin);
 // freopen("o.txt","w",stdout);
 rd(L);rd(R);rd(d);
 for(int i=L;i<=R;i++)
  if(i%d == 0)cnt++;
 printf("%d\n",cnt);
 return 0;
}
/**/

Measured memory_bytes: 3692
#include <stdio.h>
typedef long long ll;
typedef struct hoge{
    ll A;
    ll l;
    ll r;
}height;

int main(){
  ll N;
  ll ans=0;
  scanf("%lld",&N);
  ll L[N];
  ll R[N];
  height H[N];
  for(ll i = 0;i<N;i++){
    scanf("%lld",&H[i].A);
    H[i].l = i-H[i].A;
    H[i].r = i+H[i].A;
    L[i]=0;
    R[i]=0;
  }
  for(ll i = 0;i<N;i++){
    if(H[i].r < N) R[H[i].r]++;
    if(H[i].l>=0) L[H[i].l]++;
  }
  for(ll i = 0;i<N;i++) ans+=R[i]*L[i];
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 9544
import itertools
n = int(input())
count = 0
num = len(str(n))
for i in range(1,num+1):
    for balls in itertools.product([3,5,7],repeat=i):
        s = ""
        for c in balls:
            s += str(c)
        if int(s) <= n:
            lists = list(s) 
            if "7" in lists:
                if "5" in lists:
                    if "3" in lists:
                        count+=1
print(count)

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


int main(){
    long long N,D;
    cin >> N;
    vector<char>alpha = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',};

    D = 26;
    int digit = 1;

    while(0 < N - D){
        N -= D;
        D *= 26;
        digit ++;
    }

    vector<char> Ans(digit);
    N--;
    D/=26;

    for(int i = 0; i < digit; i++){
        Ans[i] = alpha[N/D];
        N %= D;
        D /= 26;
    }
    
    for(int i = 0; i < Ans.size(); i++){
        cout << Ans[i];
    }

    cout << endl;
}


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

using namespace std;

int main(){
	char s[1111];
	scanf("%s",s);
	int a = strlen(s);
	if (s[a-1] == 's'){
		strcat(s,"e");
	}
	strcat(s,"s");
	printf("%s\n",s);
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000, mod = 1000000007;

string s[100001];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s, s + n);
	ll ans = 0;
	for (int l = 0, r = 1; r < n; ++r){
		if (s[r] == s[l]){
			ans += r - l;
		}
		else {
			l = r;
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5760
// https://atcoder.jp/contests/abc123/tasks/abc123_a

#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int main()
{
  int x[5], m = -INF, k;

  REP(i, 5)
  {
    cin >> x[i];
    REP(j, i - 1)
    {
      m = max(m, abs(x[i] - x[j]));
    }
  }

  cin >> k;

  cout << (k < m ? ":(" : "Yay!") << '\n';

  return 0;
}


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

using namespace std;

const int DEFAULT = 0;

//Regular lazy propagation
struct SegmentTree {
    int n;
    vector<int> heap;
    
    SegmentTree(int n): n(n) {
        heap.assign(4 * n, DEFAULT);
    }
    
    void update(int nodeId, int l, int r, int ql, int qr, int v) {
        if (qr < l || ql > r) {
            return;
        }
        else if (ql <= l && r <= qr) {
            heap[nodeId] += v;
        }
        else {
            pushdown(nodeId);
            int m = l + (r - l)/2;
            update(nodeId * 2, l, m, ql, qr, v);
            update(nodeId * 2 + 1, m + 1, r, ql, qr, v);
        }
    }
    
      void pushdown(int nodeId) {
        if (heap[nodeId] > 0) {
            heap[nodeId * 2] += heap[nodeId];
            heap[nodeId * 2 + 1] += heap[nodeId];
            heap[nodeId] = 0;
        }
    }
    
    int query(int nodeId, int l, int r, int q) {
        if (q < l || q > r) {
            return 0;
        }
        if (l == r) {
            return heap[nodeId];
        } 
        else {
            pushdown(nodeId);
            int m = l + (r - l)/2;
            return query(nodeId * 2, l, m, q) + query(nodeId * 2 + 1, m + 1, r, q);
        }
    }
    
};

int main() {
    int n, q;
    cin >> n >> q;
    SegmentTree st(n);
    for (int i = 0; i < q; i++) {
        int cmd;
        cin >> cmd;
        if (cmd == 0) {
            int ql, qr, v;
            cin >> ql >> qr >> v;
            st.update(1, 1, n, ql, qr, v);
//            for (int i = 0; i < 4 * n; i++) {
//                cout << i << ":" << st.heap[i] << endl; 
//            }
        }
        else {
            int pos;
            cin >> pos;
            cout << st.query(1, 1, n, pos) << endl;
        }
    }
    
    return 0;
}

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

#define pi acos(-1)
typedef  long long ll;
typedef  unsigned long long ull;
typedef  unsigned un;

//defined taking input;
#define sf           scanf
#define si(a)        sf("%d",&a)
#define sc(a)        sf("%c",&a)
#define sii(a,b)     sf("%d %d",&a,&b)
#define siii(a,b,c)  sf("%d %d %d",&a,&b,&c)
#define sl(a)        sf("%lld",&a)
#define sll(a,b)     sf("%lld %lld",&a,&b);
#define slll(a,b,c)  sf("%lld %lld %lld",&a,&b,&c);

#define pf           printf
#define pfi(a)       pf("%d\n",a)
#define pfl(a)       pf("%ld\n",a)
#define pfn          pf("\n")
#define pfyes        pf("YES\n")
#define pfno         pf("NO\n")
#define pfYes        pf("Yes\n")
#define pfNo         pf("No\n")

#define wh            while
#define wht(t)        while(t--)


int main()
{
    int n;
    si(n);
    int i=1;
    while(1){
        if(n*i%360==0)break;
        i++;
    }
    cout<<i<<endl;

    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

int main(){
    
    ll a,b,k;
    cin >> k >> a >> b;
    ll ans = 1;
    if(b - a > 1 && k > a){
        k -= (a-1); ans = a;
        if(k % 2 == 1) ans += 1;
        ans += (b-a)*(k/2);
        cout << ans << endl;
    }
    else{
        cout << 1 + k << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
import collections


def main():
    x, k, d = map(int, input().split())
    a = abs(x) - k * d
    if a >= 0:
        print(a)
        return
    if(k - (abs(x) // d)) % 2 == 0:
        print(abs(x) % d)
        return
    print(abs(d - abs(x) % d))
    return


if __name__ == '__main__':
    main()


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;}
template<typename T> bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;}
typedef long long ll;

string S;

int main()
{
	cin >> S;
	reverse(ALL(S));
	cout << S << endl;

	return 0;
}

Measured memory_bytes: 3020
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
ll n;
const int maxB = 62;
const int SHIFT = 5;
ll dp[maxB + 2][2 * SHIFT + 1];
const ll mod = (ll)1e9 + 7;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    dp[maxB][SHIFT] = 1;
    ll ans = 0;
    for (int i = maxB; i >= 0; i--) {
        int his_b = (n >> i) & 1;
        for (int c1 = 0; c1 < 2; c1++) {
            for (int c2 = 0; c2 < 2; c2++) {
                if (c1 == 1 && c2 == 1) continue;
                for (int carry = -SHIFT; carry <= SHIFT; carry++) {
                    int new_val = 2 * carry - c1 - 2 * c2 + his_b;
                    new_val = min(new_val, SHIFT);
                    new_val = max(new_val, -SHIFT);
                    if (i == 0) {
                        if (new_val >= 0) {
                            ans += dp[i][carry + SHIFT];
                            ans %= mod;
                        }
                    }
                    else {
                        dp[i - 1][new_val + SHIFT] += dp[i][carry + SHIFT];
                        dp[i - 1][new_val + SHIFT] %= mod;
                    }
                }
            }
        }
    }

    cout << ans;
    return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main(void){

	int N; cin >> N;
	vector<int> H(N);
	REP(i,N) cin >> H[i];

	bool flag = true;
	H[0]--;
	FOR(i,1,N){
		if(H[i]-1 >= H[i-1]) H[i]--;
		else if(H[i] >= H[i-1]) continue;
		else flag = false;
	}

	if(flag == true) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  int A, B, C, K, ans = 0, point=1, len ;
  cin >> A >> B >> C >> K ;
  if(A >= K){
    cout << K << endl ;
    return 0 ;
  }
  ans += A ;
  K -= A ;
  if(B >= K){
    cout << ans << endl ;
    return 0 ;
  }
  K -= B ;
  ans -= K ;
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 3620
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

count = a
for i in range(8):
    a = int(s[0])
    for j in range(3):
        if i>>j&1 == 1:
            a += int(s[j+1])
        else:
            a -= int(s[j+1])
    if a == 7:
        ans = (str(bin(i))[2:]).zfill(3)
        ans = ans.replace("0","-")
        ans = ans.replace("1","+")
        print(str(s[0])+ans[2]+str(b)+ans[1]+str(c)+ans[0]+str(d)+"=7")
        break


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/


int main()
{
	while (1) {
		cin >> n;
		if (n == 0) {
			return 0;
		} else {
			ans = INF;
			for (int i = 0; i*i*i <= n; i++) {
				for (int j = 0; j*j <= n - i*i*i; j++) {
					ans = min(ans, i + j + (n - i*i*i - j*j));
				}
			}
			cout << ans << endl;
		}
	}
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> broken(n+1);
  rep(i,m) {
    int a;
    cin >> a;
    broken[a]=true;
  }
  vector<int> dp(n+1);
  dp[n]=1;
  for(int i=n-1; i>=0; i--) {
    if(broken[i]) dp[i]=0;
    else if(i==n-1) dp[i]=1;
    else dp[i]=(dp[i+1]+dp[i+2])%INF;
  }

  cout << dp[0] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll n; cin >> n;
    string s; cin >> s;
    ll t = s.size();
    rep(i,t){
        ll p = s[i]-'A';
        p = (p+n)%26;
        s[i] = p + 'A';
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdint>
#include <algorithm>

struct Statement {
public:
        std::int32_t rewrite_c;
        std::int32_t times_b;

        Statement(std::int32_t c, std::int32_t b)
                : rewrite_c(c), times_b(b){}
};

std::vector<std::int64_t> rewrite(std::vector<std::int64_t> &cards, std::vector<Statement> &steps)
{
        std::int64_t index = 0;
        std::sort(std::begin(cards), std::end(cards));
        std::sort(std::begin(steps), std::end(steps), [](const Statement &s1, const Statement &s2){
                                                              return s1.rewrite_c > s2.rewrite_c;
                                                      });
        for(int i = 0;i < steps.size();i++){
                Statement statement = steps.at(i);
                for(int n = 0;n < statement.times_b && index < cards.size();n++, index++){
                        if(cards[index] > statement.rewrite_c || index >= cards.size())
                                return cards;
                        cards[index] = statement.rewrite_c;
                }
        }

        return cards;
}

std::int64_t sum(std::vector<std::int64_t> &buf)
{
        std::uint64_t sum = 0;
        for(int i = 0;i < buf.size();i++)
                sum += buf[i];
        return sum;
}

int main(int argc, char **argv)
{
        int cards_num, do_times;
        std::cin >> cards_num >> do_times;
        std::vector<std::int64_t> cards;
        std::vector<Statement> rewrite_buf;
        cards.reserve(cards_num);

        for(int i = 0;i < cards_num;i++){
                int tmp;
                std::cin >> tmp;
                cards.push_back(tmp);
        }

        for(int i = 0;i < do_times;i++){
                std::int32_t b, c;
                std::cin >> b >> c;
                rewrite_buf.emplace_back(c, b);
        }

        auto &&rewrited = rewrite(cards, rewrite_buf);

        printf("%ld\n", sum(rewrited));
        return 0;
}


Measured memory_bytes: 2676
input = []
loop do
  input.push(gets.split(' ').map(&:to_i))
  if input[-1][0] == 0 && input[-1][1] == 0
    input.pop
    break
  end
end

input.length.times do |i|
  x = input[i][0]
  y = input[i][1]
  if x > y
    puts '%d %d' % [y, x]
  else
    puts '%d %d' % [x, y]
  end
end

Measured memory_bytes: 8768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  
  int A = a/100;
  int B = a-A*100;
  int C = B/10;
  int D = B-C*10;
 
    cout << A+C+D << endl;
 
}

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

int main(){
    int n; cin >> n;
    vector<pair<int,int> > p(n);
    rep(i,n) cin >> p[i].second >> p[i].first;
    sort(p.begin(),p.end());
    int pos=0;
    rep(i,n){
        if(p[i].first-pos<p[i].second){
            cout << "No" << endl;
            return 0;
        }
        pos+=p[i].second;
    }
    cout << "Yes" << endl;
}

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

int main(){
    int n;
    cin >> n;
    int res = 0;
    rep(i,n){
        string s = to_string(i);
        if (s.size()%2 != 0) res++; 
    }
    cout << res << endl;
}


Measured memory_bytes: 256
num, bricks = int(input()), list(map(int,input().split(" ")))
count = 1
smash = 0
for x in bricks:
    if count == x: count += 1
    else: smash += 1
print(smash if smash != len(bricks) else 0 if len(bricks) == 1 else -1)

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

#define COUT(x) cout << #x << " = " << (x) << ", "
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
typedef long long ll;
const int MOD = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  bool flag = true;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    if(A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0){
      flag = false;
      break;
    }
  }
  if(flag){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
  
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
a,b,c,d=MAP()
x=c-a
y=d-b
ans=str()
ans+="R"*x+"U"*y
ans+="L"*x+"D"*y
ans+="L"+"U"*(y+1)+"R"*(x+1)+"D"
ans+="R"+"D"*(y+1)+"L"*(x+1)+"U"
print(ans)

Measured memory_bytes: 9136