akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<long long,long long>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const long long INF = (long long)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
}

int main() {
	kekek();
	long long n;
	cin >> n;
	cout << n * (n - 1) / 2;
	// vector<int> tv;
	// while(next_permutation(nums.begin(), nums.end())) {
	// 	int ta = 0;
	// 	for (int i = 0; i < n; i++) {
	// 		ta += (i + 1) % nums[i];
	// 	}
	// 	if (ta > ans) {
	// 		ans = ta;
	// 		tv = nums;
	// 	}
	// }
	// cout << ans;
	// for (auto it: tv) {
	// 	cout << it << ' ';
	// }
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll n = in();
    vll a = in(3 * n);
    priority_queue<ll, vll, greater<ll>> l;
    priority_queue<ll> r;
    vll lsum(n + 1, 0), rsum(n + 1, 0);
    rep(i, n)
    {
        l.push(a[i]);
        lsum[0] += a[i];
        r.push(a[3 * n - 1 - i]);
        rsum[0] += a[3 * n - 1 - i];
    }

    rep(i, n)
    {
        ll la = a[n + i];
        if (l.top() < la)
        {
            lsum[i + 1] = lsum[i] - l.top() + la;
            l.pop();
            l.push(la);
        }
        else
            lsum[i + 1] = lsum[i];

        ll ra = a[n * 2 - 1 - i];
        if (r.top() > ra)
        {
            rsum[i + 1] = rsum[i] - r.top() + ra;
            r.pop();
            r.push(ra);
        }
        else
            rsum[i + 1] = rsum[i];
    }

    ll ans = -LINF;
    rep(i, n + 1)
    {
        ans = max(ans, lsum[i] - rsum[n - i]);
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int x=c+b-d,y=d-a+c,z=a-d+b,w=b+c-a;
  cout << x << ' ' << y << ' ' << z << ' ' << w << endl;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int K, A, B;
  cin >> K >> A >> B;

  for (int i = A; i <= B; ++i) {
    if (i % K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long
#define MAX 200010

signed main() {
    int n, p; cin >> n >> p;
    bool odd_flag = false;
    for(int i = 0; i < n; i++) {
        int a; cin >> a;
        if(a % 2 == 1) odd_flag = true;
    }

    if(odd_flag) {
        cout << (int)pow(2, n - 1) << endl;
        return 0;
    }


    cout << (int)pow(2, n) * (p == 1 ? 0 : 1) << endl;
    return 0;
}


Measured memory_bytes: 256
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<=b){							//a<=b
		if(b<=c)
			printf("%d %d %d\n",a,b,c); //a<=b<=c
		else if(c<=a)
			printf("%d %d %d\n",c,a,b); //c<a<=b
		else
			printf("%d %d %d\n",a,c,b);
	}else{								//b<a
		if(a<=c)
			printf("%d %d %d\n",b,a,c);
		else if(b<=c)
			printf("%d %d %d\n",b,c,a);
		else
			printf("%d %d %d\n",c,b,a);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

 

using namespace std;

 

int main()
{
    int a, b, temp, i;
    for(i=1; i<=3000; i++)
    {
        cin >> a >> b;
        
        if( a == 0 && b == 0)
            break;
        
        if(a>b)
        {
            temp = a;
            a = b;
            b = temp;
        }

        cout << a << " " << b << endl;
    }
    
}


Measured memory_bytes: 3068
#include <stdio.h>
int main() {
	int n,m;
	int temp;
	long long res=0;
	
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d",&temp);
		res+=temp;
	}
		
	if(n-res>=0){
		printf("%d",n-res);
	}else{
		printf("%d",-1);	
	}
	
	
	
    return 0;
}


Measured memory_bytes: 1732
# じょえチャンネルおもしろいよ～～～
# https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ

a,b,c,d=map(int,input().split())
aa=[a,b]
if a<=0<=b:aa.append(0)
cc=[c,d]
if c<=0<=d:cc.append(0)
ans=-10**18
for i in aa:
  for j in cc:
    ans=max(ans,i*j)
print(ans)

Measured memory_bytes: 9184
N = int(input())

N_s = int(str(N)[0])
N_e = int(str(N)[-1])
if len(str(N)) > 2:
    N_mid = int(str(N)[1:-1])
else:
    N_mid = 0

def search(s, e):
    ans = 0
    for i in range(1, len(str(N))+1):
        if i == 1:
            if s == e and s <= N:
                ans += 1
                continue
        else:
            if i != len(str(N)):
                ans += 10**(i-2)
            else:
                if N_s > s:
                    ans += 10**(i-2)
                elif N_s == s:
                    if N_e >= e:
                        ans += N_mid + 1
                    else:
                        ans += N_mid

    return ans

ret = 0
for i in range(1, 10):
    for j in range(1, 10):
        ret += search(i, j) *  search(j, i)
print(ret)

Measured memory_bytes: 3064
N = int(input())
#6
B = [int(i) for i in input().split()]
# 153 10 10 23

A = [0]*N

A[0] = B[0]
A[N-1] = B[N-2]

for i in range(1,N-1):
	A[i] = min(B[i],B[i-1])

print(sum(A))

Measured memory_bytes: 3064
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	string S;
	int w;
	cin >> S >> w;
	for (int i = 0; i < S.size(); i += w) {
		cout << S[i];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.io.IOException;

class Main{
	public static void main(String args[]){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int  n									//入力件数
			,b									//棟
			,f									//階
			,r									//部屋
			,v;									//入居者
		int[][][] house = new int[4][3][10]; 	
			
		try{
			//入力件数の入力
			n = Integer.parseInt(br.readLine());
		}catch(IOException e){
			System.out.println(e);
			return;
		}
		
		String[] input = new String[n];
		String output = "";
		
		for(int i=0;i<n;i++){
			try{
				//各情報の入力
				input = br.readLine().split("[\\s]+");
				b = Integer.parseInt(input[0]);
				f = Integer.parseInt(input[1]);
				r = Integer.parseInt(input[2]);
				v = Integer.parseInt(input[3]);
				
				house[b-1][f-1][r-1] += v;
				
			}catch(IOException e){
				System.out.println(e);
				return;
			}
		}
		
		//出力
		for(b=0;b<4;b++){
			for(f=0;f<3;f++){
				for(r=0;r<10;r++){
					output += " " + house[b][f][r];
				}
				System.out.println(output);
				output = "";
			}
			if(b<3)System.out.println("####################");
		}
		
	}
}



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

using namespace std;
typedef long long ll;
const int N = 1e5 + 10, M = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-6;

int n, m, t;

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    for(int i = 0; i < len; i++)
        cout << 'x';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int A,B,C;

    scanf("%d %d %d", &A,&B,&C);

    if(A == B && B != C && A != C)
        printf("Yes\n");
    else if(B == C && B != A && C != A)
        printf("Yes\n");
    else if(A == C && A != B && C != B)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 128
//Hello World
#include<stdio.h>
int main(){
int x,i,y;
while(1 == 1){
scanf("%d%d",&x,&y);
if(x == 0 && y == 0) break;
int tmp = x;
x = y;
y = tmp;
if(x > y){
	printf("%d %d\n", y ,x);
}else{
	printf("%d %d\n", x ,y);
}
}
return 0;
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int64_t n;
  cin >> n;
  vector<int> p;
  int64_t N=n;
  int count_sum=0;
  int ans=0;
  if(n==1){
    cout << 0 << endl;
  }else{
  for(int i=2;i<=sqrt(N);i++){
    int count =0;
    if(n%i==0){
      do{
        count++;
        n=n/i;
      }while(n%i==0);
      count_sum+=count;
      p.push_back(count);
    }    
  }
    if(n>sqrt(N)||count_sum==0){
            p.push_back(1);
    }

  for(int j=0;j<p.size();j++){
    if(p.at(j)>35){
      p.at(j)=8;
    }else if(p.at(j)>27){
      p.at(j)=7;
    }else if(p.at(j)>20){
      p.at(j)=6;
    }else if(p.at(j)>14){
      p.at(j)=5;
    }else if(p.at(j)>9){
      p.at(j)=4;
    }else if(p.at(j)>5){
      p.at(j)=3;
    }else if(p.at(j)>2){
      p.at(j)=2;
    }else{
      p.at(j)=1;
    }

   ans+=p.at(j); 
  }
  cout << ans <<endl;
}
}


Measured memory_bytes: 3688
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String answer = "";	
		String temp = "";
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			
			int shuffleTimes = scan.nextInt();
			int[] shuffleBegin = new int[shuffleTimes]; //?????£?????????????§????
			for(int i=0; i<shuffleTimes; i++){
				
			}
			
			for(int i =0;i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			answer = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					answer = answer + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					answer = answer + targetChar[j];
				}
				
			targetChar = answer.toCharArray();
			}
			System.out.println(answer);		
		}
	}
}

Measured memory_bytes: 46360
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    i64 x; cin>>x;
    i64 ans = x/11*2;
    if (x%11>6) ans+=2;
    else if (x%11!=0) ans+=1;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    String s = sc.next();
    
    String tri = null;
    String target = null;
    int ans = 0;
    
    String[] p = new String[n];
	String[] pt = new String[3];
    int cont = 0;
    int point = 0;
    
    for(int i=0; i<n; i++){
      p[i] = s.substring(i, i+1);
    }
    
    for(int i = 0; i<1000; i++){
      target = String.format("%03d", i);
      for(int k=0; k<3; k++){
        pt[k] = target.substring(k, k+1);
      }
      
      cont = 0;
      point = 0;
      for(int k=0; k<3; k++){
        for(int j=cont; j<n; j++){
          if(pt[k].equals(p[j])){
            cont = j + 1;
            point++;
            break;
          }
        }
      }
             
      if(point == 3){
        ans++;
      }
    }
             
    System.out.println(ans);
    
  }
}


Measured memory_bytes: 29268
#include<bits/stdc++.h>
using namespace std;
#define MAXN	105
#define MAXP	505
#define INF	1e8
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct edge {int dest, flow; unsigned home; };
vector <edge> a[MAXP];
unsigned curr[MAXP];
int s, t, dist[MAXP];
char mp[MAXN][MAXN];
void addedge(int x, int y, int z) {
	a[x].push_back((edge) {y, z, a[y].size()});
	a[y].push_back((edge) {x, 0, a[x].size() - 1});
}
bool bfs() {
	static int q[MAXP];
	memset(dist, 0, sizeof(dist));
	int l = 0, r = 0;
	q[0] = s; dist[s] = 1;
	while (l <= r) {
		int now = q[l];
		for (unsigned i = 0; i < a[now].size(); i++)
			if (dist[a[now][i].dest] == 0 && a[now][i].flow != 0) {
				dist[a[now][i].dest] = dist[now] + 1;
				q[++r] = a[now][i].dest;
			}
		l++;
	}
	return dist[t] != 0;
}
int dinic(int pos, int limit) {
	if (pos == t) return limit;
	int used = 0, tmp;
	for (unsigned &i = curr[pos]; i < a[pos].size(); i++)
		if (dist[a[pos][i].dest] == dist[pos] + 1 && a[pos][i].flow && (tmp = dinic(a[pos][i].dest, min(limit - used, a[pos][i].flow)))) {
			used += tmp;
			a[pos][i].flow -= tmp;
			a[a[pos][i].dest][a[pos][i].home].flow += tmp;
			if (used == limit) return used;
		}
	return used;
}
int main() {
	int n, m;
	read(n), read(m);
	s = 0, t = n + m + 1;
	for (int i = 1; i <= n; i++) {
		scanf("\n%s", mp[i] + 1);
		for (int j = 1; j <= m; j++) {
			if (mp[i][j] == 'S') {
				addedge(s, i, INF);
				addedge(s, j + n, INF);
			}
			if (mp[i][j] == 'T') {
				addedge(i, t, INF);
				addedge(j + n, t, INF);
			}
			if (mp[i][j] == 'o') {
				addedge(i, j + n, 1);
				addedge(j + n, i, 1);
			}
		}
	}
	int ans = 0;
	while (bfs()) {
		memset(curr, 0, sizeof(curr));
		ans += dinic(s, INF);
	}
	if (ans >= INF) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

int f(int b, int n) {
    if (n < b)return n;
    return f(b, n / b) + n % b;
}

int N, S;

signed main() {
    cin >> N >> S;
    if (N == S) {
        cout << N + 1 << endl;
        return 0;
    }
    int rn = sqrt(N) + 1;
    for (int b = 2; b <= rn; ++b) {
        if (f(b, N) == S) {
            cout << b << endl;
            return 0;
        }
    }
    for (int p = rn; p >= 1; --p) {
        int b = (N - S) / p + 1;
        if (b >= 2) {
            if (f(b, N) == S) {
                cout << b << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 384
def accepted(S: str)->bool:
    if S[0] != 'A':
        return False
    if sum(1 for c in S[2:-1] if c == 'C') != 1:
        return False

    sorted_s = ''.join(sorted(S)[2:])
    return sorted_s == sorted_s.lower()


if __name__ == "__main__":
    S = input()
    ac = accepted(S)
    print('AC' if ac else 'WA')


Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a,b,k=1,s=0,n,w,m,min=100000000000,ans=1,max=0;
    string s3;
    cin >> w >> a >> b;
    if(a < b){
        ans = b-(w+a);
    }
    else {
        ans = a-(w+b);
    }
    if(ans<0)
        cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int H, A;
	cin >> H >> A;
	ce((H+A-1)/A)
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int ara1[100];
int main()
{
    int n,d,x,a,i,j,s,sum=0;
    cin>>n>>d>>x;
    int ara[n];
    for(i=0;i<n;i++){
        cin>>ara[i];
    }
    for(i=0;i<n;i++){
            s=1;
      while(s<=d){
        ara1[s]++;
        s+=ara[i];
      }
    }
    for(i=1;i<=d;i++){
        sum+=ara1[i];
    }
    cout<<sum+x<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int main () {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for (int i = 1; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      for (int k = 0; k < 10; ++k) {
        int x = 10001*i + 1010*j + 100*k;
        if (a<=x && x<=b) ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio

  ll a, b;
  cin >> a >> b;
  cout << max(0LL, a - 2 * b) << '\n';

  ktj();
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main() 
{
    int sum;
    int in_n, in_y;
    int z;
    int flg;
 
   
   scanf("%d %d",  &in_n, &in_y);
   flg = 0;
 for (int i = 0; i <= in_n; i++) {
   for(int j = 0; j <= in_n - i; j++) {
        z = in_n - i - j;
        sum = 10000 * i + 5000 * j + 1000 * z;
        if (sum == in_y && z >= 0) {
            printf("%d %d %d\n", i, j, z);
            flg = 1;
            break;
        }
      }
      if (flg == 1) {
      	break;
      }
    }
    if (flg == 0) {
        printf("-1 -1 -1\n");
    }
    return 0;
}

Measured memory_bytes: 128
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B,K; R(A,B,K);
    for(int i=A;i>0;i--){
        if(A%i==0&&B%i==0){
            K--;
            if(!K){
                W(i);
                return 0;
            }
        }
    }
    return 0;
}


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

int main() {
    int max = 100;
    int n;
    cin >> n; // take the input
    int p[max + 1], m[max + 1][max + 1];
    for (int i = 1; i <= n; i++) {
        cin >> p[i - 1] >> p[i]; // scan in the matrix
    }

    for (int i = 1; i <= n; i++) {
        m[i][i] = 0;
        for (int t = 2; t <= n; t++) {
            for (int i = 1; i <= n - t + 1; i++) {
                int j = i + t - 1;
                m[i][j] = (1 << 21);
                for (int k = i; k <= j - 1; k++) {
                    m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
                }
            }
        }
    }

    cout << m[1][n] << endl;
    return 0;
}


Measured memory_bytes: 3124
//#pragma GCC         optimize("O3")
#include            <bits/stdc++.h>
#include            <ext/pb_ds/assoc_container.hpp>
#include            <ext/pb_ds/tree_policy.hpp>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define mp          make_pair
#define mem(x,i)    memset(x,i,sizeof(x))
#define ff          first
#define ss          second
#define popcount(x) __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define D(x)        cerr<< __LINE__ <<": "<< #x << " = "<<(x) <<'\n';
#define endl        '\n'

using namespace std;
using namespace __gnu_pbds;

using ll  = long long;
using ld  = long double;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;

const int INF    = 0x3f3f3f3f;
const ll LL_INF  = 0x3f3f3f3f3f3f3f3f;
const double PI  = acos(-1);
const double eps = 1e-4;
const int mod    = 1e9+7;
const int mx     = 2e3+5;
template <typename T>  using orderedSet =
    tree<T, null_type, less_equal<T>,
    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key*/

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

//ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(; b; b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
/*----------------------BitMask-----------------------------------------*/
//inline int setBit(int N,int pos){return N=N | (1<<pos);}
//inline int resetBit(int N,int pos){return N= N & ~(1<<pos);}
//inline bool checkBit(int N,int pos){return (bool) (N& (1<<pos));}
int ans[mx];
bool vis[mx];
int dis[mx];
vector<int>adj[mx];
void bfs(int src)
{
    queue<int>q;
    q.push(src);
    vis[src]=1;
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int v: adj[u])
        {
            if(!vis[v])
            {
                vis[v]=1;
                dis[v]=dis[u]+1;
                ans[dis[v]]++;
                q.push(v);
               // cout<<u<<' '<<v<<' '<<dis[v]<<endl;
            }
        }
    }
}
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<n;i++) adj[i].pb(i+1),adj[i+1].pb(i);
    adj[x].pb(y);
    adj[y].pb(x);
    for(int i=1;i<=n;i++)
    {
        mem(vis,0);
        mem(dis,0);
        bfs(i);
    }
    for(int i=1;i<n;i++) cout<<ans[i]/2<<endl;
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m;
  cin >> n >> m;
  vector<P> v(m);
  rep(i, 0, m) {
    int p, y;
    cin >> p >> y;
    v[i] = make_pair(p, y);
  }
  vector<P> v2(m);
  v2 = v;
  sort(v2.begin(), v2.end());

  int cur = 0, sub_no = 0;
  map<P, int> ans;
  rep(i, 0, m) {
    if (cur != v2[i].first) {
      cur = v2[i].first;
      sub_no = 1;
    }
    ans[v2[i]] = sub_no;
    sub_no++;
  }

  rep(i, 0, m) { printf("%06d%06d\n", v[i].first, ans[v[i]]); }
}


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

int main()
{
	int s;
	int before;
	int l[100000] = {0};

	scanf("%d", &s);

	for (int i = 1; i < 100000; i++)
	{
		int a;

		if (i == 1)
			a = s;
		else
		{ 
			if (before % 2 == 0)
			{
				a = before / 2;
			}
			else
			{
				a = before * 3 + 1;
			}
		}

		for (int j = 1; j < i; j++)
		{
			if (a == l[j])
			{
				printf("%d\n", i);
				return false;
			}
		}

		before = a;
		l[i] = a;
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vd vector<double>
#define f(i,l,r) for(ll i=l;i<r;i++)
#define d(i,n,m) for(ll i=n;i>=m;i--)
#define P (ll)1e9+7
#define pb push_back
#define F first
#define S second
#define IP ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
int offset[]={1,0,-1,0,1};
int main()
{
    IP
    ll n,m;
    cin>>n>>m;
    vl height(n+1),adj[n+1];
    f(i,0,n)
        cin>>height[i+1];
    f(i,0,m)
    {
        ll u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    vl vis(n+1,0);
    ll ans=0;
    f(i,1,n+1)
    {
        if(vis[i])
        continue;
        bool check=1;
        for(auto v:adj[i])
        {
            if(height[i]<=height[v])
            {
                check=0;
                break;
            }
            else vis[v]=1;
        }
        if(check)
        ans++;
        vis[i]=1;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 10588
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <cstdio>
using namespace std;
#define mygc(c) (c)=getchar()
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;} }for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}

int64_t A[5000];
int B[5000][200];

int main(){
    int N,M;
    reader(&N); reader(&M);
    for(int i=1;i<N;i++){
        int a;
        reader(&a);
        A[i]=(int64_t)a+A[i-1];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            reader(&B[i][j]);
        }
    }
    int64_t ans=0;
    for(int i=0;i<N;i++){
        int32_t T[200] = {};
        for(int j=i;j<N;j++){
            int64_t temp=A[i]-A[j];
            for(int k=0;k<M;k++){
                T[k]=max(T[k],B[j][k]);
            }
            for(int k=0;k<M;k++){
                temp+=T[k];
            }
            ans=max(ans,temp);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
#include <cstdio>
#include <queue>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> a(n);
    bool zero=1;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i])zero=0;
    }
    vector<int> b(n+1,0);
    for(int i=0;i<n;i++){
        int l=max(0,i-a[i]);
        int r=min(n,i+a[i]+1);
        b[l]++;
        b[r]--;
    }
    for(int i=1;i<n;i++){
        b[i]+=b[i-1];
    }
    //
    k--;
    while(k--){
        for(int i=0;i<n;i++){
            a[i]=b[i];
            b[i]=0;
        }
        for(int i=0;i<n;i++){
            int l=max(0,i-a[i]);
            int r=min(n,i+a[i]+1);
            b[l]++;
            b[r]--;
        }
        bool ok=1;
        for(int i=1;i<n;i++){
            b[i]+=b[i-1];
        }
        for(int i=0;i<n;i++){
            if(b[i]!=n){
                ok=0;
                break;
            }
        }
        if(ok)break;
    }
    for(int i=0;i<n;i++){
        cout << b[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  string ans = "YES";
  if(N % 2 == 0) {
    if(K > N/2) ans = "NO";
  }else {
    if(K > N/2+1) ans = "NO";
  }
  
  cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    vector< long long > v(n+1,0),l(n);
    long long temp;
    long long sum=0,ss;
    for(long long i=0;i<n;i++)
    {
        cin>>temp;
        l[i]=temp;
        v[temp]++;
    }
    for(long long i=1;i<n+1;i++)
    {
        if(v[i]>1)
        {
            sum=sum+((v[i]*(v[i]-1))/2);
        }
    }
    for(long long i=0;i<n;i++)
    {
        if(v[l[i]]>1)
        {
            ss=sum-((v[l[i]]*(v[l[i]]-1))/2)+(((v[l[i]]-1)*(v[l[i]]-2))/2);
        }
        else
        {
            ss = sum;
        }
        
        cout<<ss<<endl;
    }
    return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    string S;
    cin >> S;
    rep(i,0,3){
        if(S[i] == S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
}

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

typedef long long ll;
ll MOD = 1000000007;

struct bit {
	vector<ll> v;
	bit(int n) : v(n + 1) {}
	ll sum(int i) {
		ll res = 0;
		for (; i > 0; i -= i & -i) res += v[i];
		return res;
	}
	void add(int i, ll x) {
		for (i++; i < v.size(); i += i & -i) v[i] += x;
	}
};

int B = 800;

int main() {
	int N; cin >> N;
	vector<int> p(N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
		p[i]--;
	}
	vector<vector<int> > num(N / B + 1, vector<int>(N + 1));
	for (int i = 0; i < N; i++)
		num[p[i] / B][i + 1]++;
	for (int j = 0; j <= N / B; j++)
		for (int i = 0; i < N; i++)
			num[j][i + 1] += num[j][i];
	int Q; cin >> Q;
	vector<vector<int> > query(N);
	vector<int> l(Q), r(Q);
	for (int q = 0; q < Q; q++) {
		scanf("%d%d", &l[q], &r[q]);
		l[q]--; r[q]--;
		query[r[q]].push_back(q);
	}
	vector<int> index(N, -1);
	bit bt(N);
	vector<int> A(N / B + 1);
	vector<vector<int> > v(N / B + 1);
	vector<vector<ll> > sum(N / B + 1, vector<ll>(1));
	ll cur = 0;
	vector<ll> ans(Q);
	for (int i = 0; i < N; i++) {
		for (int x = N - 1; x > p[i];) {
			if (x % B == B - 1 && x - B >= p[i]) {
				A[x / B]++;
				cur += v[x / B].size();
				x -= B;
			}
			else {
				if (index[x] != -1) {
					bt.add(index[x], 1);
					cur++;
				}
				x--;
			}
		}
		int x = p[i];
		index[x] = i;
		ll prev = sum[x / B].back();
		v[x / B].push_back(i);
		sum[x / B].push_back(prev + A[x / B]);
		for (int k = 0; k < query[i].size(); k++) {
			int q = query[i][k];
			ans[q] = cur - bt.sum(l[q]);
			for (int i = 0; i <= N / B; i++) {
				int j = num[i][l[q]];
				ans[q] -= (ll)j * A[i] - sum[i][j];
			}
		}
	}
	for (int q = 0; q < Q; q++)
		printf("%lld\n", ans[q]);
}

Measured memory_bytes: 63412
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int count(ll x){
	int cnt = 0;
	while(x != 0){
		cnt++;
		x /= 10;
	}
	return cnt;
}
int main()
{
	int n; cin>>n;
	vector< int > v;
	int sum=0;
	for(int i = 0 ; i < n ; i++){
		int x; cin>>x;
		sum+=x;
		if(x%10)v.push_back(x);
	}
	sort(v.begin() , v.end());
	if(v.size()==0){
		cout<<"0"; return 0;
	}
	if(sum%10!=0) cout<<sum;
	else cout<<sum-v[0];
	return 0;
} 




Measured memory_bytes: 256
from collections import deque
#import sys
#input = sys.stdin.readline

s = deque(list(input()))
q = int(input())
rev = -1

for i in range(q):
    a = list(input().split())
    if a[0] == '1': #T1
        rev *= -1 
    
    else: #T2
        if a[1] == '1': #Fi = 1
            if rev == -1:
                s.appendleft(a[2])
            else:
                s.append(a[2])
                
        else: #Fi = 2
            if rev == -1:
                s.append(a[2])
            else:
                s.appendleft(a[2])
                
if rev == -1:
    print(''.join(s))
else:
    s = list(s)
    print(''.join(s[::-1]))

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin>>n;
	string s; cin>>s;
	ll ans = 1;
	rep(i, n-1){
		if (s[i]!=s[i+1]) ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	for(int i=1;i<200;i*=2){
		if(n==i){
			cout << i << endl;
			return 0;
		}
		if(n<i){
			cout << i/2 << endl;
			return 0;
		}
	}
}

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

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;



long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}


//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}



int main() {

	long long ans=0;

	int N, Q;

	vector <int> A;

	vector<vector<int>> BC;

	int memo[100100] = {};

	cin >> N;

	int tmp3;

	for (int i = 0; i < N; i++) {
		cin >> tmp3;
		A.push_back(tmp3);
	}

	cin >> Q;

	int tmp1, tmp2;

	for (int i = 0; i <Q; i++) {
		cin >> tmp1;
		cin >> tmp2;
		vector<int> tmp;
		tmp.push_back(tmp1);
		tmp.push_back(tmp2);
		BC.push_back(tmp);
	}


	for (int i = 0; i < N; i++) {
		ans += A[i];
		memo[A[i]]++;
	}

	for (int i = 0; i < Q; i++) {
		if (memo[BC[i][0]] != 0) {
			ans += memo[BC[i][0]] * (BC[i][1] - BC[i][0]);
			memo[BC[i][1]] += memo[BC[i][0]];
			memo[BC[i][0]] = 0;
		}
		cout << ans << endl;
	}


	cin >> ans;

	return 0;


}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int f(int z) {
  int Z = pow(z, 3);
  int ac = INF;
  range (x, 1, z) {
    int X = x * x* x;
    if (X > Z) break;
    range (y, 1, z) {
      int Y = y * y * y;
      if (X + Y > Z) break;
      ac = min<int>(ac, Z - X - Y);
    }
  }
  return ac;
}

int main() {
  for (int z; cin >> z, z; ) cout << f(z) << '\n';
  return 0;
}

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


int main(){

  ll a,b;
  cin>>a>>b;
	
 
  if(a==b){cout<<a<<endl;return 0;}
  
  if((a+b)%2==0){cout<<(a+b)/2<<endl;return 0;}
  
  cout<<"IMPOSSIBLE"<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>

int main()
{
	int A = 0, B = 0, K = 0;
	double C = 0;
	std::string ans = "IMPOSSIBLE";

	std::cin >> A >> B;

	C = (A + B) / 2.0;

	double eps = 10e-6;
	if (fabs(ceil(C) - C) < eps){
		K = (int)ceil(C);
		ans = std::to_string(K);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
//templates
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <map>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <queue>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define sort_key(struct_name,key_name) [](const struct_name &x, const struct_name &y){return x.key_name < y.key_name;}
#define pb(x) push_back(x)
typedef long long ll;
const long long MOD = 1e9 + 7;
using namespace std;

//main
int main(){
    int A,B; cin >> A >> B;
    if(2*B >= A) cout << 0 << endl;
    else cout << A-2*B << endl;
}


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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)n; ++i)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;


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

 	int n;
 	string s;
 	cin >> n >> s;
 	n %= 26;
 	for (int i = 0; i < s.length(); i++) {
 		s[i] = 'A' + (s[i] - 'A' + n) % 26;
 	}
 	cout << s << endl;	

  	
  	

          	
}	

  // cout << "Case #" << c++ << ": " << ans << endl;  



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

int main() {
  ll n;
  cin >> n;
  vl h(n);
  rep(i,n) cin >> h[i];
  ll ans = 0, cnt = 0;
  rep(i,n-1) {
    if (h[i] >= h[i+1]) cnt++;
    else cnt = 0;
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}

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

int main(){
 int N;
 int M;
 int a[50];
 int b[50];
 int c;
 int i;
 int ans=0;
 cin>>N>>M;
 for(c=0;c<M;c++){
 	cin>>a[c]>>b[c];
 }
 //計算
 for(c=1;c<=N;c++){
 	for(i=0;i<M;i++){
		if(a[i]==c){
			ans++;
		}
		if(b[i]==c){
			ans++;
		}
	}
 	cout<<ans<<endl;
	ans=0;
 }
}

Measured memory_bytes: 256