akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {

	char s, ans;
	cin >> s;
	if (s=='A') ans = 'T';
	if (s=='T') ans = 'A';
	if (s=='G') ans = 'C';
	if (s=='C') ans = 'G';

    cout << ans << "\n";
    return 0;
}

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

ans = s.count('R') *  s.count('G') *  s.count('B')

for i in range(n):
    for j in range(i+1, n):
        k = 2 * j - i

        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
         
print(ans)

Measured memory_bytes: 9192
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	--a;
	ll ac = a / c;
	ll ad = a / d;
	ll acd = a / lcm(c, d);
	ll bc = b / c;
	ll bd = b / d;
	ll bcd = b / lcm(c, d);
	ll ans = (b - bc - bd + bcd) - (a - ac - ad + acd);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 4016
#define mod 1000000007

const int delta = 2003;

int n, i, j;
pair<int, int> ske[200011];

ll dp[maxN][maxN];
ll fact[maxN * 2], inv_fact[maxN * 2];
ll ans;

ll poww(ll a, ll b) {
    ll ans = 1;

    while (b > 0) {
        if (b & 1) ans = (ans * a) % mod;
        b >>= 1;
        a = (a * a) % mod;
    }

    return ans;
}

ll comb(ll n, ll k) {
    ll ans = (fact[n] * inv_fact[k]) % mod;
    ans *= inv_fact[n - k];
    return ans % mod;
}

void pre() {
    int i;

    fact[0] = 1;
    for (i = 1; i <= 4 * delta; i++) fact[i] = (fact[i - 1] * i) % mod;

    inv_fact[4 * delta] = poww(fact[4 * delta], mod - 2);
    for (i = 4 * delta - 1; i > 0; i--)
        inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % mod;

    inv_fact[0] = 1;
}

int main()
{
 //   freopen("test.in","r",stdin);

    pre();

    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%d%d", &ske[i].first, &ske[i].second);
        ans += mod - comb(2 * ske[i].first + 2 * ske[i].second, 2 * ske[i].second);
        dp[delta - ske[i].first][delta - ske[i].second]++;
    }

    for (i = 1; i <= 2 * delta; i++) {
        for (j = 1; j <= 2 * delta; j++) {
            dp[i][j] += dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] %= mod;
        }
    }

    for (i = 1; i <= n; i++)
        ans += dp[delta + ske[i].first][delta + ske[i].second];

    ans %= mod;
    ans *= poww(2, mod - 2);
    ans %= mod;

    printf("%lld", ans);



    return 0;
}


Measured memory_bytes: 127616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef complex<double> Point;
#define X real()
#define Y imag()

double dot(Point a, Point b) {
	return a.X*b.X + a.Y*b.Y;
}

Point proj(Point a1, Point a2, Point p) {
	return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

Point reflection(Point a1, Point a2, Point p) {
  return 2.0*proj(a1, a2, p) - p;
}

int main(void){
	double x1,y1,x2,y2,x,y;
	int q;
	cin>>x1>>y1>>x2>>y2>>q;
	rep(i,q){
		cin>>x>>y;
		Point p=reflection({x1,y1},{x2,y2},{x,y});
		printf("%.9f %.9f\n",p.X,p.Y);
	}
	return 0;
}

Measured memory_bytes: 3344
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
#include <numeric>
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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

const int MAX_N = 1002;

int main() {
	int ans = 0;
	double sa_max = 1919810.0;
	int n;
	int t, a;
	int h[MAX_N];
	cin >> n;
	cin >> t >> a;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < n; i++) {
		double ave_tmp = (double)t - ((double)h[i] * 0.006);
		double sa_i = abs((double)a - ave_tmp);
		if (sa_max > sa_i) {
			sa_max = sa_i;
			ans = i + 1;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
  string str;
  cin >> str;
  for(int i=0; i<str.size(); i++){
    if(str[i] == '?'){
      if(str[i-1] == 'P'){str[i]='D';}
      else if(str[i+1] == 'D'){str[i]='P';}
      else if(str[i+1] == '?'){str[i]='P';}
      
      else{str[i] = 'D';}
    }
  }
  cout << str;
  
return 0;
}

Measured memory_bytes: 3484
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int cnt1 = 0;
		int cnt2 = 0;

		while(true) {

			int H = sc.nextInt();
			int W = sc.nextInt();

			if(H == 0 && W == 0)
				break;

			for(cnt1 = 0; cnt1 < W; cnt1++ ) {

				System.out.print("#");

			}

			System.out.println("");

			for(cnt2 = 0; cnt2 < H-2; cnt2++) {

				System.out.print("#");

				for(cnt1 = 0; cnt1 < W-2; cnt1++ ) {

					System.out.print(".");

				}

				System.out.println("#");

			}

			for(cnt1 = 0; cnt1 < W; cnt1++ ) {

				System.out.print("#");

			}
			System.out.println("");
			System.out.println("");
		}
		sc.close();}
}


Measured memory_bytes: 34736
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int kansu(int i){
  if(i==25964)
    return 0;
    else return i;
}

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while( cur != nil && cur->key != key ){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  //  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t = listSearch(key);
  if ( t == nil ) return;
  deleteNode(t);
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if(!( 0 <= key && key <= 2000000000)){printf("error") ;}
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
    if ( size > 1000000 ) { printf("error"); }
  }

  
  if(!( np+nd <= 2000000)){printf("error") ;}
  if(!( nd <= 20)){printf("error") ;}
  printList();


  return 0;
}


Measured memory_bytes: 36072
n, c = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(c)]
C = [list(map(int, input().split())) for _ in range(n)]

for i in range(n):
    for j in range(n):
        C[i][j] -= 1

cnt_color_by_r = [dict() for _ in range(3)]

for r in range(3):
    for clr in range(c):
        cnt_color_by_r[r][clr] = 0

for i in range(n):
    for j in range(n):
        cnt_color_by_r[(i + j) % 3][C[i][j]] += 1

costs = [[0 for _ in range(c)] for _ in range(3)]

for r in range(3):
    for after in range(c):
        cost = 0
        for before in range(c):
            cost += D[before][after] * cnt_color_by_r[r][before]
        costs[r][after] = cost

cost_r0 = list(sorted([(after, costs[0][after]) for after in range(c)], key=lambda x: x[1]))[:3]
cost_r1 = list(sorted([(after, costs[1][after]) for after in range(c)], key=lambda x: x[1]))[:3]
cost_r2 = list(sorted([(after, costs[2][after]) for after in range(c)], key=lambda x: x[1]))[:3]

ans = float('inf')
for c0, cost0 in cost_r0:
    for c1, cost1 in cost_r1:
        for c2, cost2 in cost_r2:
            if c0 != c1 and c1 != c2 and c2 != c0:
                ans = min(ans, cost0 + cost1 + cost2)

print(ans)

Measured memory_bytes: 5620
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	string s;
	ll sum=0, wcnt = 0;
	cin >> s;
	map<char, int>mp;
	rep(i, s.size()) {
		if (s[i] == 'W') {
			sum += (ll)i - wcnt;
			wcnt++;
		}
	}
	cout << sum << endl;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    lint ans = 0, q, h, s, d, n;
    cin >> q >> h >> s >> d >> n;
    q *= 8;
    h *= 4;
    s *= 2;
    ans += min({q, h, s, d}) * (n / 2);
    if(n % 2 == 1){
        q /= 2;
        h /= 2;
        s /= 2;
        ans += min({q, h, s});
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] p = new int[n];
			IntStream.range(0, n).forEach(i -> p[i] = scanner.nextInt());
			System.out.println(getResult(p, 0));
		}
	}

	/**
	 * @param p     数字の配列
	 * @param start 開始インデックス
	 * @return 最小の入替え数
	 */
	private static int getResult(int[] p, int start) {
		int next = -1;
		for (int i = start; i < p.length; i++) {
			if ((i + 1) == p[i]) {
				next = i;
				break;
			}
		}
		if (next >= 0) {
			int result = Integer.MAX_VALUE;
			if (next == p.length - 1) {
				result = getResult(swap(p, next - 1), next - 1) + 1;
			} else {
				result = getResult(swap(p, next), next) + 1;
			}
			return result;
		}
		return 0;
	}

	/**
	 * @param p     数字の配列
	 * @param index インデックス
	 * @return 数字の配列のインデックスとインデックス＋1の要素を入替えた配列
	 */
	private static int[] swap(int[] p, int index) {
		int temp = p[index];
		p[index] = p[index + 1];
		p[index + 1] = temp;
		return p;
	}
}


Measured memory_bytes: 65472
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 15
#define PI 3.141592653589793
#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 go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fi(a, b, c, d) for(int a = b; a < c; a += d)
#define fl(a, b, c, d) for(ll a = b; a < c; a += d)
#define fei(a, b, c, d) for(int a = b; a <= c; a += d)
#define fel(a, b, c, d) for(ll a = b; a <= c; a += d)
#define quit exit(0)
#define mem(x, a) memset(x, a, sizeof x)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcl pair<char, ll>
#define psl pair<string, ll>


ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
unordered_map<ll, ll> mp;
set<ll> s;
string S = "";
ll cases;
ll hons[5] = {2, 4, 5, 7, 9};
ll pons[4] = {0, 1, 6, 8};
ll bons[1] = {3};

int main() {
	go;
    cin >> N;
    ll lastDig = N % 10;
    fi(i, 0, 5, 1) {
    	if(hons[i] == lastDig) {
    		cout << "hon\n";
    		quit;
    	}
    }
    fi(i, 0, 4, 1) {
    	if(pons[i] == lastDig) {
    		cout << "pon\n";
    		quit;
    	}
    }
    	cout << "bon\n";
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 3584
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    s = list(str(input()))
    t = list(str(input()))

    s.sort()
    s = "".join(s)
    t.sort(reverse=True)
    t = "".join(t)

    if t > s:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 2940
//a
#include <iostream>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <memory>
#include <functional>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>

#define REP(i,b,n) for(int i=b;i<n;i++)
#define REPR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define EACH(i, c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define BIT(n, b) ((n>>b) & 1)
#define PB push_back
#define MP make_pair

using namespace std;

static const double PI = acos(-1.0);
static const double EPS = 1e-9;
typedef long long ll;
typedef pair<int, int> pii;	
	
int n, p[4];
int yard[5000][5000];
	
int main(){
	
	cin >> n;
	
	for(int i=0; i<4; ++i){
		cin >> p[i];
		p[i]--;
	}
	
	int tmp, res = INT_MAX;
	
	for(int w=n; w>0; --w){
		
		tmp = abs(p[0]/w - p[1]/w) +  abs(p[0]%w - p[1]%w) 
			+ abs(p[2]/w - p[3]/w) +  abs(p[2]%w - p[3]%w);
		
		res = min(res, tmp);
	}
	
	cout << res << endl;
	
	return 0;	
}

Measured memory_bytes: 1164
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

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

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


#line 2 "abc165_c.cpp"

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m, q;
  cin >> n >> m >> q;
  m++;
  vi a(q), b(q), c(q), d(q);
  REP(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  int ans = 0;
  FOR(i0, 1, m) {
    FOR(i1, i0, m) {
      FOR(i2, i1, m) {
        FOR(i3, i2, m) {
          FOR(i4, i3, m) {
            FOR(i5, i4, m) {
              FOR(i6, i5, m) {
                FOR(i7, i6, m) {
                  FOR(i8, i7, m) {
                    FOR(i9, i8, m) {
                      int val[10] = {i0, i1, i2, i3, i4, i5, i6, i7, i8, i9};
                      vi now(n);
                      REP(i, n) { now[i] = val[i]; }
                      int tmp = 0;
                      REP(i, q) {
                        if (now[b[i]] - now[a[i]] == c[i])
                          tmp += d[i];
                      }
                      chmax(ans, tmp);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define scan(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define print(n) printf("%d",n)
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          1061109567
#define ninf         LONG_MIN
#define fast()         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const   ll mod=1e9+7;
const ll N=1e5+5;


 
int main() 
{ 
          fast();
          #ifndef ONLINE_JUDGE
          freopen("input.txt" , "r" , stdin);
          freopen("output.txt" , "w" , stdout);
         #endif
          int k;
          cin >> k;
          int count=0;
          int num = 0;
          bool visited[k];
          memset(visited,0,sizeof(visited));
          bool flag = false;
          while (1){
            count++;
            num = (num * 10 + 7) % k;
            if (num == 0){
              cout << count << endl;
              flag = true;
              break;
            }
            if (visited[num] != 0){
              break;
            }
            visited[num] = 1;
          }
          if (!flag){
            cout << -1 << endl;
          }
 
           return 0; 

} 

Measured memory_bytes: 4636
n=int(input())
a=list(map(int, input().split()))
b=a.sort(reverse=True)
for i in range(n-1):
    if a[i]==a[i+1]:
        for j in range(i+2,n-1):
            if a[j]==a[j+1]:
                print(a[i]*a[j])
                exit()
else:
    print(0)

Measured memory_bytes: 85416
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
using namespace std;

const string YES = "Yes";
const string NO = "No";
bool flag;

bool solve(std::string S, std::string T){
    for(int i=0;i<S.size();i++){
        //cout<<(S[i]!=T[i]);
        if(S[i]!=T[i])return false;
    }
    if(S.size()+1!=T.size()){
        //cout<<"hoge";
        return false;
    }
    return true;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    
    flag=solve(S, T);
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  ll h,n;
  cin>>h>>n;
  VI dp(h+1,INF);
  dp[0]=0;
  VI a,b;
  for(i=0;i<n;i++) {
    ll s,t;
    cin>>s>>t;
    for(j=0;j<15;j++){
      a.pb(s);
      b.pb(t);
      s*=2;
      t*=2;
      if(s>=4*h) break;
    }
  }
  for(i=0;i<a.size();i++){
    for(j=h;j>=0;j--){
      ll u=j+a[i];
      if(u>=h) u=h;
      dp[u]=min(dp[u],dp[j]+b[i]);
    }
  }
  cout<<dp[h]<<endl;




  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int A,B,C;
	cin>>A>>B>>C;
	if(A*C<=B)cout<<C<<endl;
	else{
		int n=0;
		while(A*n<=B){
			n+=1;
		}
		cout<<n-1<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

#----------------------------------------------------

X, Y = map(int, input().split())


if (X+Y)%3 == 0:
    L=(2*Y-X)//3
    R=(2*X-Y)//3

    p = 10 ** 9 + 7
    N = 10 ** 6  # N は必要分だけ用意する
    fact = [1, 1]  # fact[n] = (n! mod p)
    factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
    inv = [0, 1]  # factinv 計算用

    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)

    print(cmb(L+R, min(L,R), p))
else:
    print(0)


Measured memory_bytes: 127560
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n, a;
	cin >> n >> a;
	vector<int>x(n);
	for (int i = 0;i < n;i++) {
		cin >> x[i];
		x[i] -= a;
	}
	long long int dp[51][5000] = {};
	dp[0][2500] = 1;
	for (int i = 1;i <= n;i++) {
		for (int j = 0;j < 5000;j++) {
			if (j >= x[i - 1]) {
				dp[i][j] = dp[i - 1][j] + dp[i - 1][j - x[i - 1]];
			}
			else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}
	cout << dp[n][2500] - 1 << endl;
	return 0;
}

Measured memory_bytes: 2176
object Main {
  def main(args: Array[String]): Unit = {
    val num     = scala.io.StdIn.readInt
    val heights = scala.io.StdIn.readLine.split( " " ).map{ _.toLong }

    var total_step_height = 0L
    var max_height        = 0L

    heights.foreach{ i =>
      if( max_height > i ) {
        total_step_height += max_height - i
      }
      else {
        max_height = i
      }
    }

    println( total_step_height )

  }
}

Measured memory_bytes: 86548
n, m = map(int, input().split())
h = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(m)]
b = set()
for i, j in a:
    if h[i-1] < h[j-1]:
        b.add(i-1)
    elif h[i-1] > h[j-1]:
        b.add(j-1)
    else:
        b.add(j-1)
        b.add(i-1)


print(n-len(b))

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

int main(){
	int a;
	int b;
	int c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a < b && b < c){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}	


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a1[2005],a2[105],a3[105];
int main()
{
    ll a,b,c,d,e,f,g,i,j,k,l,m,n,o,p,q,r,s,t,tc,u,v,ans;
    long double w,x,y,z;
    string ss;
    cin>>a;ans=0;
    for(i=1;i<=a;i++)
    {
        b=a/i;
        c=i*b*(b+1)/2;
        ans=ans+c;
    }
    cout<<ans;

    return 0;
}


Measured memory_bytes: 3520
S = input()

l = [0] * (len(S) + 1)
l[1] = 1
if S[0] == S[1]:
    l[2] = 1
else:
    l[2] = 2

for i in range(3, len(S)+1):
    if S[i-1] != S[i-2]:
        l[i] = l[i-1] + 1
    else:
        l[i] = l[i-3] + 2

print(l[-1])


Measured memory_bytes: 11240
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000000
#define VMAX 10000

int n,i,j;
unsigned short *A, *B;
 int C[VMAX+1];

int main(){
  
  scanf("%d", &n);
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0; i<=VMAX; i++)C[i]=0;
  for(i=0;i<n;i++){
    scanf("%hu", &A[i+1]);
    C[A[i+1]]++;
  }

  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];
 
  for(j=1; j<=n;j++){
       B[C[A[j]]] = A[j];
       C[A[j]]--;}
  
  for(i=1;i<=n;i++){
    if(i!=n)printf("%d ", B[i]);
    else if(i=n)printf("%d",B[i]);
}
    printf("\n");
  return 0;
}




Measured memory_bytes: 9616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll mod = 1e9+7;
const int MAXN = 2e5+5;

int32_t main() {
	int a;
	string s;
	cin >> a >> s;
	
	cout << (a >= 3200 ? s : "red") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
    double a, b;
    cin >> a >> b;
    cout << int(a/b) << " " << int(fmod(a,b)) << " ";
	 cout << fixed << setprecision(10) << a/b << endl;
    return 0;
}


Measured memory_bytes: 3336
#B

n,x = (int(x) for x in input().split())
l = [int(x) for x in input().split()]

d = 0
count = 0

for i in range(n):
    if d <= x:
        count += 1
    else:
        break
        
    d += l[i]
else:
    if d <= x:
        count += 1

print(count)
        


Measured memory_bytes: 38384
#include<cstdio>
long long n,x;
long long ans(long long n,long long x)
{
	if (n%x==0) return (2*(n/x)-1)*x;
	return ans(x,n%x)+2*(n/x)*x;
}
int main()
{
	while (~scanf("%lld%lld",&n,&x)) printf("%lld\n",ans(n-x,x)+n);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  ll N,A[300000],S[300000],ans=0;
  cin>>N;
  S[0]=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    S[i+1]=S[i]+A[i];
  }
  sort(S,S+N+1);
  ll rensa=1;
  for(int i=0;i<N;i++){
    if(S[i]==S[i+1]) {
      ans+=rensa++;;
    }else rensa=1;
    
  }
  cout<<ans<<endl;
}


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

typedef long long ll;
ll n, a, b;

int main() {
    cin >> n >> a >> b;
    if (a > b || (a != b && n < 2)) return puts("0"), 0;
    printf("%lld\n", (n - 1) * b + a - ((n - 1) * a + b) + 1);
    return 0;
}


Measured memory_bytes: 3692
#include<cstdio>
#include<functional>
#include<algorithm>
#include<cstring>
using namespace std;
int main(void)
{
	char s[4];
	scanf("%s",s);
	sort(s,s+3);
	if(strcmp(s,"abc")==0)	{
		printf("Yes\n");
	}
	else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

 #define rep(i, a, b) for (int i = a; i <= b; i++)

 typedef long long LL;

 LL a, b, c;
 int cnt;
 bool flag;

int main()
{
	scanf("%lld%lld%lld", &a, &b, &c);
	if ((a & 1LL) || (b & 1LL) || (c & 1LL)) { puts("0"); return 0; }
	cnt = 0;
	flag = false;
	while (cnt <= 5000000) {
		cnt++;
		LL h1 = a >> 1LL, h2 = b >> 1LL, h3 = c >> 1LL;
		a = h2 + h3;
		b = h1 + h3;
		c = h1 + h2;
		if ((a & 1LL) || (b & 1LL) || (c & 1LL)) { flag = true; break; }
	}
	printf("%d\n", flag ? cnt : -1);

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
// 104, 79, 118, 87
// 169, 133, 17, 98
// 180, 106, 125, 39
// 171, 42, 159, 14
// 45, 76, 101, 56
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	long long ret=0;
	long long ks=1;
	long long ret2=0;
	for(int i=0;i<a;i++)for(int j=0;j<a;j++){
		printf("? %d %d %d %d\n",i,j,i,j);
		fflush(stdout);
		int t;
		scanf("%d",&t);
		if(t)ret=(ret+ks)%d;
		if(i==0)ret2=(ret2+ks)%d;
		ks=ks*2%d;
	}
	int sz=d%200;
	char *p = new char[sz*1000000];
	for(int i=0;i<sz*1000000;i++)p[i]='e';
	printf("! %lld\n",ret);
}

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

#define QUEUE_DATA_MAX 100000

typedef struct ST_QueueData QueueData_t;

struct ST_QueueData{
    char name_buff[10];    /* Name Buffer */
    int  time_buff;        /* Time Buffer */
	QueueData_t *next;     /* Next Point */
}QUEUE_DATA;

QueueData_t tQueueDataBuffer[QUEUE_DATA_MAX];

int main(void)
{
    int  pn;                      /* process num */
    int  pt;                      /* process time */
    int  data_num = 0;
    int  elapsed_time = 0;
    QueueData_t *ptBeforeNext;    /* Befor Next Point */
    QueueData_t *ptQueueDataNow;  /* Now Queue Data Point */
    
    /* get "process num" & "process time" */
    scanf("%d %d", &pn, &pt);
     
    /* get Name & time */
    while((scanf("%s %d", tQueueDataBuffer[data_num].name_buff, &(tQueueDataBuffer[data_num].time_buff)) != EOF) && data_num < QUEUE_DATA_MAX)
    {
        data_num++;
    	tQueueDataBuffer[data_num-1].next = &(tQueueDataBuffer[data_num]);
    }
    
	tQueueDataBuffer[data_num-1].next = &(tQueueDataBuffer[0]);
	ptQueueDataNow = &(tQueueDataBuffer[0]);
	ptBeforeNext = &(tQueueDataBuffer[data_num-1]);
	
    /* get Data Num equal process num */
    if( data_num == pn )
    {
        while(pn > 0)
        {
            /* remain process time */
            if( ptQueueDataNow->time_buff > pt )
            {
                ptQueueDataNow->time_buff -= pt;
                elapsed_time += pt;
                ptBeforeNext = ptQueueDataNow;
           }
            else
            {
                elapsed_time += ptQueueDataNow->time_buff;
                printf("%s %d\n", ptQueueDataNow->name_buff, elapsed_time); /* output finished process */
                ptQueueDataNow->time_buff = 0;
                ptBeforeNext->next = ptQueueDataNow->next;                  /* dequeue */
                pn--;
            }
             
            /* Next buffer point */
            ptQueueDataNow = ptQueueDataNow->next;
        }
    }
    else
    {
        /* error input */
    }
     
    return 0;
}

Measured memory_bytes: 2872
#include<iostream>
#include<string>
using namespace std;
int main(){
	string N;
	cin >> N;
	bool flag = true;
	for(int i = 1; i < N.length(); i++){
		if(N[i] != '9') flag = false;
	}
	if(flag) cout << 9 * (N.length() - 1) + (N[0] - '0') << endl;
	else cout << 9 * (N.length() - 1) + (N[0] - '0') - 1 << endl;
	return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a == b) cout << "Draw" << endl;
    else if(a == 1) cout << "Alice" << endl;
    else if(b == 1) cout << "Bob" << endl;
    else if(a > b) cout << "Alice" << endl;
    else cout << "Bob" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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 (a>b) { a = b; return 1; } return 0; }
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


int main(){
    ll a, b;
    cin >> a >> b;
    ll res = (a+b)/2;
    if ((a+b)%2 != 0) res++;
    cout << res << "\n";
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))
    Da=[-(-(b-a)//2) for a,b in zip(A,B) if a<b]
    Db=[a-b for a,b in zip(A,B) if a>b ]
    if sum(B)-sum(A)>=max(sum(Da),sum(Db)):print("Yes")
    else:print("No")

if __name__=='__main__':
    main()

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

const int N = (int) 1e5 + 5;

int n;
vector <int> g[N];
vector <pair <int, int> > edge;
map <pair <int, int>, int> colorEdge;
bool used[N];
int c[N];

int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v; cin >> u >> v;
		edge.push_back({u, v});
		g[u].push_back(v);
		g[v].push_back(u);
	}
	queue <int> q;
	q.push(1); used[1] = true;
	int nColor = 0;
	while (!q.empty()) {
		int u = q.front(); q.pop();
		nColor = max(nColor, (int) g[u].size());
		int cur = 1;
		for (auto v: g[u]) {
			if (used[v]) continue;
			if (cur == c[u]) cur++;
			c[v] = colorEdge[{u, v}] = colorEdge[{v, u}] = cur++;
			used[v] = true;
			q.push(v);
		}
	}
	cout << nColor << "\n";
	for (auto e: edge) cout << colorEdge[e] << "\n";
	return 0;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int M;
    cin >> M;
    cout << 24 + 24 - M << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int MX=1e9;
int main(){
	int n,s,k;
	scanf("%d%d%d",&n,&s,&k);
	if (k==1e9){
		for (int i=1; i<=s; i++)
			printf("%d ",MX);
		for (int i=s+1; i<=n; i++)
			printf("%d ",1);
	}
	else {
		for (int i=1; i<=s; i++)
			printf("%d ",k);
		for (int i=s+1; i<=n; i++)
			printf("%d ",MX);
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll m=1000000007;
int main()
{
	ll h,w;
	cin>>h>>w;
	ll dp[1002][1002];
	memset(dp,0,sizeof(dp));
	string s[h];
	for (ll i=0;i<h;i++)
		cin>>s[i];
	ll f=1;
	for (ll i=1;i<w;i++)
	{
		if (s[0][i]!='#'&&f)
			dp[0][i]=1;
		else
			{
				dp[0][i]=0;
				f=0;
			}
	}
	f=1;
	for (ll i=1;i<h;i++)
	{
		if (s[i][0]!='#'&&f)
			dp[i][0]=1;
		else
			{
				dp[i][0]=0;
				f=0;
			}
	}
	for (ll i=1;i<h;i++)
	{
		for (ll j=1;j<w;j++)
		{
			if (s[i][j]=='.')
			{
				dp[i][j]=(dp[i-1][j]%m+dp[i][j-1]%m)%m;
			}
		}
	}
	cout<<dp[h-1][w-1]%m;
}

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

int main() {
  int A, B,C,D;
  cin >> A >> B>>C>>D;

  if (A+B<C+D)
  cout << "Right"<< endl;
  else if(A+B==C+D)
  cout<< "Balanced"<<endl;
  else if(A+B>C+D)
  cout << "Left"<<endl;


}

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max({a * c, a * d, b * c, b * d});
    return 0;
}

Measured memory_bytes: 3688
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& o) {
  out << "(" << o.first << "," << o.second << ")";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& V) {
  for (int i = 0; i < V.size(); i++) {
    out << V[i];
    if (i != V.size() - 1) out << " ";
  }
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<vector<T> >& Mat) {
  for (int i = 0; i < Mat.size(); i++) {
    if (i != 0) out << endl;
    out << Mat[i];
  }
  return out;
}
template <class S, class T>
ostream& operator<<(ostream& out, const map<S, T>& mp) {
  out << "{ ";
  for (auto it = mp.begin(); it != mp.end(); it++) {
    out << it->first << ":" << it->second;
    if (mp.size() - 1 != distance(mp.begin(), it)) out << ", ";
  }
  out << " }";
  return out;
}
template <typename T>
vector<T> make_v(size_t a) {
  return vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T& t, const V& v) {
  t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T& t, const V& v) {
  for (auto& e : t) fill_v(e, v);
}
/*
 <url:https://atcoder.jp/contests/agc026/tasks/agc026_c>
 問題文============================================================
 C - String Coloring
 =================================================================
 解説=============================================================
 ================================================================
 */

template <class Type>
Type solve(Type res = Type()) {
  int N;
  cin >> N;
  string S;
  cin >> S;
  string lS = S.substr(0, N);

  string rS = S.substr(N, 2 * N);
  reverse(rS.begin(), rS.end());

  using pss = pair<string, string>;
  map<pss, ll> mp;
  {  // lSから赤・青の組み合わせを列挙
    for (int i = 0; i < (1 << N); i++) {
      string r, b;
      for (int j = 0; j < N; j++) {
        if ((i >> j) & 1) {
          r += lS[j];
        } else {
          b += lS[j];
        }
      }
      reverse(b.begin(), b.end());
      mp[make_pair(r, b)]++;
    }
  }
  {  // rSから赤・青の組み合わせを列挙　⇒　lSでのmapを用いて計算
    for (int i = 0; i < (1 << N); i++) {
      string r, b;
      for (int j = 0; j < N; j++) {
        if ((i >> j) & 1) {
          b += rS[j];
        } else {
          r += rS[j];
        }
      }
      reverse(b.begin(), b.end());
      res += mp[make_pair(r,b)];
    }
  }
  // cout << mp << endl;
  return res;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // solve<ll>(0);
  cout << fixed << setprecision(12) << solve<ll>() << endl;
  return 0;
}

Measured memory_bytes: 60872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int gcd(int a,int b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
int main(){
  int i,n,a[5];
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  int x=gcd(a[0],a[1]);
  if(n==3){
    x=gcd(x,a[2]);
  }
  vector<int> y;
  for(i=1;i*i<=x;i++){
    if(x%i==0){
      y.push_back(i);
      if((x/i)!=i){
        y.push_back(x/i);
      }
    }
  }
  sort(y.begin(),y.end());
  for(i=0;i<y.size();i++){
    cout << y[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3124
#include<stdio.h>
int min(int a,int b){return a>b?b:a;}
int f(int x){return x>0?x:-x;}
int g(int x){return x%3;}
int a[200010],dp[4];
int main(){
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	dp[1]=f(a[1]-a[0]);
	dp[2]=f(a[2]-a[0]);
	for(i=3;i<n;i++)dp[g(i)]=min(dp[g(i-1)]+f(a[i]-a[i-1]),dp[g(i-2)]+f(a[i]-a[i-2]));
	printf("%d",dp[g(n-1)]);
	return 0;
}

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

const double PI=acos(-1.0);

int main(){
    int n;
    cin >> n;
    set<int> st;
    rep(i, n) {
        int d;
        cin >> d;
        st.insert(d);
    }

    cout << st.size() << endl;

    return 0;
}

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

int nis[12];

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

    int tmp;
    for (int i = 0; i < d; i++) {
        cin >> tmp;
        nis[tmp] = 1;
    }

    while (1) {
        int num = n;
        bool flg = false;
        while (num) {
            flg = true;
            int rem = num % 10;
            if (nis[rem]) {n++; flg = false; break;}
            num /= 10;
        }
        if (flg) break;
    }

    cout << n << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, m; cin >> n >> m;
    VL x(n), y(m); cin >> x >> y;

    ll a = 0, b = 0;
    FOR(i, 0, n - 1) {
        ll wid = x[i + 1] - x[i];
        (a += wid * (i + 1LL) * (n - 1LL - i)) %= mod;
    }
    FOR(i, 0, m - 1) {
        ll wid = y[i + 1] - y[i];
        (b += wid * (i + 1LL) * (m - 1LL - i)) %= mod;
    }

    cout << a * b % mod << "\n";
}


Measured memory_bytes: 1792
{-# LANGUAGE BangPatterns #-}

import Data.Bits
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.ByteString.Char8 as B

freqMapWithParity :: [Int] -> (IntMap Int, IntMap Int)
freqMapWithParity
  = foldl' (\(!now,!prev) k -> (prev, IntMap.insertWith (+) k 1 now))
    $ (IntMap.empty, IntMap.empty)

obtainFreq :: IntMap Int -> (Int, Int, Int, Int)
obtainFreq = IntMap.foldlWithKey' loop (minBound, 0, minBound, 0)
  where
    loop (!v1, !n1, !v2, !n2) !v !n
      | n >= n1   = (v,  n,  v1, n1)
      | n >= n2   = (v1, n1, v,  n)
      | otherwise = (v1, n1, v2, n2)

chooseBest ::
  (Int, Int, Int, Int) -> (Int, Int, Int, Int) -> ((Int, Int), (Int, Int))
chooseBest (!lv1, !ln1, !lv2, !ln2) (!rv1, !rn1, !rv2, !rn2)
  | lv1 /= rv1             = ((lv1, ln1), (rv1, rn1))
  | ln1 + rn2 >= ln2 + rn1 = ((lv1, ln1), (rv2, rn2))
  | otherwise              = ((lv2, ln2), (rv1, rn1))

query :: Int -> [Int] -> Int
query n vs = n - ln - rn
  where
    (l,r) = freqMapWithParity vs
    lf = obtainFreq l
    rf = obtainFreq r
    ((_, ln), (_, rn)) = chooseBest lf rf

main :: IO ()
main = do
  n <- read <$> getLine
  vs <- unfoldr (B.readInt . B.dropWhile (== ' ')) <$> B.getLine
  putStrLn $ show $ query n vs

Measured memory_bytes: 17916
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

const int MAX = 2e3 + 5;
vector <int> adj[MAX];
bool vis[MAX];
int dist[MAX][MAX];
void init(int x)
{
	for(int i = 0; i < MAX; i++){
		dist[x][i] = inf;
		vis[i] = false;
	}
}
void bfs(int x)
{
	init(x);
	vis[x] = true;
	queue <int> q;
	q.push(x);
	dist[x][x] = 0;
	while(!q.empty()){
		int p = q.front();
		q.pop();
		for(auto v : adj[p]){
			if(!vis[v]){
				vis[v] = true;
				q.push(v);
				dist[x][v] = min(dist[x][v], dist[x][p] + 1);
			}
		}
	}
}
int main()
{
	boost;
	int n, x, y, i, j;
	cin >> n >> x >> y;
	foe(i, 1, n - 1) {
		adj[i].pb(i + 1);
		adj[i + 1].pb(i);
	}
	adj[x].pb(y);
	adj[y].pb(x);
	
	foe(i, 1, n)
	bfs(i);
	int ans[n];
	fill(ans, ans + n, 0);
	foe(i, 1, n) {
		foe(j, i + 1, n)
		ans[dist[i][j]]++;
	}
	fo(i, 1, n)
	cout << ans[i] << '\n';
}


Measured memory_bytes: 16000
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
const ll m = 998244353;

const ll s = 1e6 + 2;
ll a[s];

int main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();

    /* long long yaad se daal de har jagah*/
    #define int long long

    int n;
    cin>>n; 
    int sum = 0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[x]++;
        sum+=x;
    }
    int q;
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        sum-=(b*a[b]);
        sum+=(c*a[b]);
        a[c] += a[b];
        a[b] = 0;
        cout<<sum<<"\n";
    }
}

Measured memory_bytes: 4380
#include <stdio.h>

int main(void){

    int n;
    scanf("%d", &n);
    int num[100] ={0};


    int i =0;
for (; i < n; i++){
    scanf("%d",&num[i]);

}

for (i = n - 1; i >=0; i--){
    printf("%d", num[i]);
    if(i!=0){printf(" ");}
}
printf("\n");
    
    return 0;
}


Measured memory_bytes: 2068
#include <cstdio>
#include <iostream>
#include <math.h>

using namespace std;

int main(){
	int n;
	int A[8],B[8];
	int a,b;

	scanf("%d",&n);
	for(int u=0;u<n;u++){
		int atotal=0,btotal=0;

		scanf("%d",&a);
		for(int t=7;t>=0;t--){
			B[t] = A[t] = (int)(a / pow(10,t)) % 10;
		}
		

		//?°??????????
		for(int i=1;i<8;i++){
			int v=A[i];
			int j=i-1;
			while(j >= 0 && A[j] > v){
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
		}


		//??§?????????
		for(int i=1;i<8;i++){
			int v=B[i];
			int j=i-1;
			while(j >= 0 && B[j] < v){
				B[j+1] = B[j];
				j--;
			}
			B[j+1] = v;
		}


		for(int i=7;i>=0;i--){
			atotal += A[i] * pow(10,i);
		}

		for(int i=7;i>=0;i--){
			btotal += B[i] * pow(10,i);
		}

		cout << atotal - btotal << endl;

	}

}

Measured memory_bytes: 3276