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

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

  int res = 0;

  if (a != b) {
    int c = min(a, b);
    int d = max(a, b);

    res = c;
    for (int i = 0; i < d - 1; i++) {
      res *= 10;
      res += c;
    }
  }
  else {
    res = a;
    for (int i = 0; i < a - 1; i++) {
      res *= 10;
      res += a;
    }
  }

  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

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

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

#define rep(i,n) for(int i=0; i<n; i++)

short map[50][50];
int w, h;

void dfs(int x, int y) {
    map[x][y] = 0;
    int d[3] = {-1,0,1};
    rep(i, 9) {
        int xx = x+d[i%3];
        int yy = y+d[i/3];
        if( 0<=xx && xx<w && 0<=yy && yy<h && map[xx][yy]==1 ) {
            dfs( xx, yy );
        }
    }
}

int main(){
    while( cin >> w >> h, w||h ) {
        int lands = 0;
        rep(y,h) rep(x,w) cin >> map[x][y];
        rep(y, h) {
            rep(x, w) {
                if( map[x][y] == 1 ) {
                    lands++;
                    dfs(x, y);
                }
            }
        }
        cout << lands << endl;
    }
    return 0;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

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

    string s; cin >> s;
    int num=0;
    rep(i,s.size()){
        num+=s[i]-'0';
    }
    yn(num%9==0);
}

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

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

    vector<int> d(n);

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

    sort(d.begin(), d.end());

//    cout << d[n/2-1] << endl;
//    cout << d[n/2] << endl;

    cout << d[n/2] - d[n/2-1] << endl;

}


Measured memory_bytes: 640
// Lec10-B Triangle
#include<iostream>
#include<cmath>
#include<iomanip>
int main(){
  int a, b, C;
  std::cin >> a >> b >> C;
  std::cout << std::fixed << std::setprecision(8) << a*b*sin(C*M_PI/180)/2 << std::endl;
  std::cout << std::fixed << std::setprecision(8) << a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C*M_PI/180)) << std::endl;
  std::cout << std::fixed << std::setprecision(8) << b*sin(C*M_PI/180) << std::endl;
  return 0;
}

Measured memory_bytes: 3492
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
int N;
bool check(char T[400][400]) {
    rep(i, N) {
        rep(j, N) {
            if (T[i][j] != T[j][i]) return false;
        }
    }
    return true;
}


signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    char S[400][400];
    rep(i, N) {
        rep(j, N) {
            cin >> S[i][j];
        }
    }
    int ans = 0;
    rep(A, N) {
        char T[400][400];
        rep(i, N) {
            rep(j, N) {
                int x = (i + A) % N;
                T[x][j] = S[i][j];
            }
        }
        ans += check(T);
    }
    cout << ans * N << endl;
    

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        int V = 0;
        for (int i = 0 ; i < N ; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
            V += v[i];
        }
        long[][] dp = new long[N+1][V+1];

        for (int j = 1 ; j <= V; j++) {
            dp[0][j] = 100000000000l;
        }
        for (int i = 0 ; i < N ; i++) {
            for (int j = 0 ; j <= V; j++) {
                if (j < v[i]) {
                    dp[i + 1][j] = dp[i][j];
                } else {
                    dp[i + 1][j] = Math.min(dp[i][j], dp[i][j - v[i]] + w[i]);
                }
            }
        }
        int res = 0;
        for (int i = 0 ; i <= V ; i++) {
            if (dp[N][i] <= W) {
                res = i;
            }
        }
        System.out.println(res);

    }

}

Measured memory_bytes: 126032
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    h,w = map(int, input().split())
    t=[list(map(int, input().split())) for _ in range(h)]
    sum_row=[0]*h
    sum_column=[0]*w
    for i,row in enumerate(t):
        for j,a in enumerate(row):
            sum_row[i]+=a
            sum_column[j]+=a
    for i,row in enumerate(t):
        print(*t[i],sum_row[i])
    print(*sum_column,sum(sum_column))

main()



Measured memory_bytes: 6244
#include <stdio.h>

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

int main(void){
    int n;
    scanf("%d",&n);
    call(n);
    return 0;
}


Measured memory_bytes: 2088
a,b,c = map(int,input().split())
cnt = 0
def f(a,b,c):
	return b//2 + c//2, a//2 + c//2, a//2 + b//2

while (a%2==0 and b%2==0 and c%2==0):
	if a==b and b==c and c==a:
		print('-1')
		exit()
	else:
		cnt += 1
		a,b,c = f(a,b,c)
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int n;
    cin>>n;

    vi v(n);
    mii m;
    fo(i,n){
        cin>>v[i];
        m[v[i]]++;
    }
    int cnt = 0;
    for(auto i : m){
        if(i.ss>1){
            cnt += (i.ss*(i.ss-1))/2;
        }
    }
    for(int i = 0;i<n;i++){
        if(m[v[i]]<2) cout<<cnt<<"\n";
        else if(m[v[i]]==2) cout<<cnt-1<<"\n";
        else{
            int x = m[v[i]];
            cout<<cnt - x*(x-1)/2 + (x-1)*(x-2)/2<<"\n";
        }
    }
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

using namespace std;

int main(){
  int n=0;
  cin>>n;
  int a[n];
  double sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  double ave=sum/n;
  double b[n];
  for(int i=0;i<n;i++){
    b[i]=abs(ave-a[i]);
  }
  double min=b[0];
  int min_num=0;
  for(int i=0;i<n;i++){
    if(min>b[i]){
      min=b[i];
      min_num=i;
    }
  }
  cout<<min_num<<endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
x=list(map(int,input().split()))
ans=float("inf")
for i in range(n-k+1):
    left = x[i]
    right = x[i+k-1]
    ans = min(ans,abs(left)+abs(right - left),abs(right) + abs(right - left))
print(ans)

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

#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define go(x, i) for(register int i = head[x]; i; i = nxt[i])
#define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i)
#define FOR(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_end_; -- i)
#define debug(x) cout << #x << " = " << x << endl
#define mem(a, b) memset(a, b, sizeof(a))
#define cpy(a, b) memcpy(a, b, sizeof(a))
#define min(a, b) (a < b ? a : b)
#define max(a, b) (b < a ? a : b)
#define inf (0x3f3f3f3f)
#define INF (1e18)
#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef unsigned long long ull;
typedef unsigned int uint;
typedef long long ll;
typedef std::pair<ll, int> PLI;
typedef std::pair<int, int> PII;
typedef long double ldb;
typedef double db;

using namespace std;
const int N = 1e3 + 10;

int n, m, d[N];

struct Point {
	int x, y;
}A[N];

void Solve(int x, int y) {
	FOR(i, 30, 0) {
		int now = 1 << i;
		if(abs(x) >= now) {
			if(x > 0) x -= now, putchar('R');
			else x += now, putchar('L');
		}
		else if(abs(y) >= now) {
			if(y > 0) y -= now, putchar('U');
			else y += now, putchar('D');
		}
		else {
			if(abs(x) > abs(y)) {
				if(x < 0) x += now, putchar('L');
				else x -= now, putchar('R');
			}
			else {
				if(y < 0) y += now, putchar('D');
				else y -= now, putchar('U');
			}
		}
	}
	if(x != 0 || y != 0) puts("fuck");
}

int main() {
#ifdef ylsakioi
	file("d");
#endif
	cin >> n; For(i, 1, n) cin >> A[i].x >> A[i].y;
	int flag = abs(A[1].x + A[1].y) & 1;
	For(i, 2, n) if((abs(A[i].x + A[i].y) & 1) ^ flag) return puts("-1"), 0;
	cout << (32 - flag) << endl;
	FOR(i, 30, 0) cout << (1 << i) << ' ';
	puts(flag ? "" : "1");
	if(!flag) For(i, 1, n) ++ A[i].y;
	For(i, 1, n) {
		Solve(A[i].x, A[i].y); 
		puts(flag ? "" : "D");
	}
	return 0;
}


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

row=sorted(map(int,input().split()))

cnt=0

for i in range(len(row)):
  for j in range(i+1,len(row)):
    for k in range(j+1,len(row)):
      if row[i]!=row[j] and row[j]!=row[k] and row[i]!=row[k]:
        if (abs(row[j]-row[i]) < row[k]) and (row[k] < row[j]+row[i]):
          cnt+=1

print(cnt)

Measured memory_bytes: 9068
import java.util.*;

public class Main {

	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double sum = 0;
		for (int i = 0; i < n; i++) {
			sum += inverse(sc.nextInt());
		}
		System.out.println(inverse(sum));
	}
	
	static double inverse(double x) {
		return 1 / x;
	}
}


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

end = []
flag = 1
for i in range(len(s)):
  if s[i] not in end:
    end.append(s[i])
    for j in range(len(t)):
      if s[i] == s[j]:
        if t[i] != t[j]:
          flag = 0
      else:
        if t[i] == t[j]:
          flag = 0

if flag == 0:
  print('No')
else:
  print('Yes')

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define all(x) (x).begin(), (x).end()
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return 0;}while(0)

const int MOD = 1e9+7;
const int MAXN = 5e5+3;
const int INF = 1e9;


int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    function<int(int,int)> gcd = [&](int a, int b) {
        if (b == 0) return a;
        return gcd(b,a%b);
    }; 

    int k; cin >> k;
    int ans = 0;
    fore(a,1,k) 
        fore(b,1,k) {
            int g = gcd(a,b);
            fore(c,1,k) ans += gcd(g,c);
        }

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


Measured memory_bytes: 3620
import sys
import heapq

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

q = ni()

lh = []
hh = []
ln = 0
hn = 0
ls = 0
hs = 0
off = 0
for z in range(q):
    line = na()
    if line[0] == 1:
        _, a, b = line
        off += b

        if len(lh) > 0:
            mid = -lh[0]
            if a <= mid:
                heapq.heappush(lh, -a)
                ls += a
                ln += 1
            else:
                heapq.heappush(hh, a)
                hs += a
                hn += 1
        else:
            heapq.heappush(lh, -a)
            ls += a
            ln += 1

        while ln < hn:
            mx = heapq.heappop(hh)
            hs -= mx
            hn -= 1
            ls += mx
            ln += 1
            heapq.heappush(lh, -mx)

        while ln > hn + (ln+hn)%2:
            mx = -heapq.heappop(lh)
            ls -= mx
            ln -= 1
            heapq.heappush(hh, mx)
            hs += mx
            hn += 1
    else:
        lls = -lh[0]*ln - ls
        hhs = hs - (-lh[0]*hn)
        print(-lh[0], lls+hhs+off)

Measured memory_bytes: 79576
s = int(input())

y1 = int(1e9)
x2 = s//y1 + (0 if s == int(1e18) else 1)

x1 = 1
y2 = x2*y1-s

ans = [0, 0, x1, y1, x2, y2]

print(" ".join(map(str, ans)))

Measured memory_bytes: 9104
# coding:UTF-8
import sys

if __name__ == '__main__':
    # ------ 入力 ------#
    # 1行入力
    a = int(input())    # 数字
    # a = input()     # 文字列
    # a = list(map(int, input().split()))     # スペース区切り連続数字
    # a = input().split()     # スペース区切り連続文字列
    # a = [int(c) for c in input()]   # 数字→単数字リスト変換

    # 定数行入力
    x = 5
    # a = [int(input()) for _ in range(x)] # 数字
    # a = [input() for _ in range(x)] # 文字
    # a = [list(map(int, input().split())) for _ in range(x)]     # スペース区切り連続数字(行列)
    # a = [input().split() for _ in range(x)]     # スペース区切り連続文字
    # a = [[int(c) for c in input()] for _ in range(x)]  # 数字→単数字リスト変換(行列)

    # スペース区切り連続 数字、文字列複合
    # a = []
    # for _ in range(x):
    #     aa, bb = input().split()
    #     a.append((int(aa), bb))

    # ------ 出力 ------#
    if a == 1:
        print("0")
    if a == 0:
        print("1")


Measured memory_bytes: 9044
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	int n; cin >> n;
	int ans = 1;
	for (int i = 1; i <= n; i++) {
		ans = ans * i % MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int n;
	cin>>n;
	int ans=100000;
	for(int i=0;i<n;i++){
	ans+=ans*5/100;
	if(ans%1000)ans+=(1000-ans%1000);
	}
	
	
	cout<<ans<<endl;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    ll A[N], B[N];
    rep(i,0,N){
        cin>>A[i];
    }
    rep(j,0,N){
        cin>>B[j];
    }
    vector<ll> m;
    vector<ll> p;
    rep(i,0,N){
        if(A[i]<B[i]) m.push_back(B[i]-A[i]);
        if(A[i]>B[i]) p.push_back(A[i]-B[i]);
    }
    sor(p);
    rev(p);
    int k=0;
    int u=-1;
    int i=0;
    while(i<sz(m)){
        if(*(p.end()-1)==0){
            cout <<-1<<"\n";
            return 0;
        }
        if(p[k]>m[i]){
            p[k]-=m[i];
            m[i]=0;
            u=k;
            i++;
        }
        else if(p[k]==m[i]){
            p[k]=0;
            u=k;
            k++;
            i++;
        }
        else{
            m[i]-=p[k];
            p[k]=0;
            u=k;
            k++;
        }
    }
    cout <<u+1+sz(m)<<"\n";
}


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

using namespace std;

const int MAX_N = 100000;

int main() {
    int H, N, A[MAX_N];
    cin >> H >> N;

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

    for (int i = 0; i < N; i++) {
        H -= A[i];
        if (H <= 0) {
            cout << "Yes" << endl;
            exit(0);
        }
    }

    cout << "No" << endl;
}


Measured memory_bytes: 640
def main():
  n,k,*t=map(int,open(0).read().split())
  e=[set()for _ in[0]*n]
  for a,b in zip(t[::2],t[1::2]):
    e[a-1]|={b-1}
    e[b-1]|={a-1}
  c,q=k,[0]
  e=tuple(e)
  while q:
    v,i=q.pop(),1
    for w in e[v]:
      c=c*(k-i-(v>0))%(10**9+7)
      e[w].discard(v)
      q+=w,
      i+=1
  print(c)
main()

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

int main() {
    string S;
    cin >> S;
    if(S == "SUN")cout << "7" << endl;
    if(S == "MON")cout << "6" << endl;
    if(S == "TUE")cout << "5" << endl;
    if(S == "WED")cout << "4" << endl;
    if(S == "THU")cout << "3" << endl;
    if(S == "FRI")cout << "2" << endl;
    if(S == "SAT")cout << "1" << endl;
}

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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define f(i,n) for(int i=0 ; i<n ; i++)
#define fll(i,n) for(ll i=0 ; i<n ; i++)
#define f1(a,b,i) for(ll i=a ; i<b ; i++)
#define fd(i,n) for(int i=n-1 ; i>=0 ; i--)
#define ll long long
#define ld long double
#define vi vector<int>
#define  pii pair<int,int>
#define vl vector<ll>
#define INF 1e9
#define epsn 1e-12

using namespace std ;
int M=1e9+7 ;
ll pow(ll a, ll b){
    if(b==0)return 1 ;
    else if(b%2)return a*pow(a,b-1) ;
    else return pow(a,b/2)*pow(a,b/2) ;
}

int main(){
   ll ans,t ;
    for(int i=1 ; i<6 ; i++){
	cin>>t ;
     if(t!=i)ans=i ;
    }
  cout<<ans<<"\n";
  return 0 ;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

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

	int X,Y;
	int i,j;
	int tmp;
	int answer=0;
	int counter=0;
	vector<int> given;

	cin >> X >> Y;

	for(i=0;i<=100;i++){
		for(j=0;j<=100;j++){
			if(2*i+4*j==Y && i+j==X){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<int> ve;
typedef pair<int, int> pa;
typedef vector<pair<ll,ll> > vepa;
typedef map<int, int> mp;
const ll N=1e5+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
ll cnt[N]={};
bool f;
 int main()
{
 ll n,need,yen=0;
  vepa vp;
  cin>>n>>need;
  rep(i,n)
  {
      ll a,b;
      cin>>a>>b;
      vp.p_b(m_p(a,b));
  }
  sort(all(vp));
  rep(i,n)
  {
    /*  if(need==0)
      {
          cout<<yen;
          go;
      }*/
     if(vp[i].S<need)
     {
         need-=vp[i].S;
         yen+=vp[i].F*vp[i].S;
     }else if(vp[i].S==need)
     {
         yen+=(vp[i].F*vp[i].S);
         cout<<yen;
         go;
     }else
     {
         yen+=(need*vp[i].F);
         cout<<yen;
         go;
     }

  }

go;
}


Measured memory_bytes: 2420
s=input()
if len(s)==26:
	d=[]
	for i in range(26):
		if list(s[-i-1:][::-1])!=sorted(s[-i-1:]):
			for j in range(i+1):
				d.append(s[-j-1])
			d.sort()
			for j in range(len(d)):
				if d[j]>s[-i-1]:
					k=d[j]
					break
			print(s[:-i-1]+k)
			exit()
	print(-1)
	exit()
d=[0]*26
for i in range(len(s)):
	d[ord(s[i])-ord("a")]+=1
for i in range(26):
	if d[i]==0:
		x=chr(ord("a")+i)
		break
print(s+x)

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

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)


/*
#define nMX 5000000
#define pMX 500000
int pr[pMX+1],prnum[nMX+1];

int sieve()
{
    int i,j;
    for(i=1;i<=nMX;i++)
        prnum[i]=i+1;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            for(j=2*prnum[i]-1;j<=nMX;j+=prnum[i])
                    prnum[j]=-1;
    j=0;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            pr[++j]=prnum[i];
    re j;
}*/

/*ll m_ncr[10001][10001];
ll ncr(ll i,ll j)
{
    if(j==1) re i;
    if(i==j) re 1;
    if(m_ncr[i][j]!=-1) re m_ncr[i][j];
    re m_ncr[i][j]=ncr(i-1,j) + ncr(i-1,j-1);
}*/

ll mod = 1000000007LL;

ll mem[5][5][5][200],n;

ll go(ll p1, ll p2, ll p3, ll i)
{
    if(i>n) re 1;
    if(mem[p1][p2][p3][i]!=-1) re mem[p1][p2][p3][i];
    ll r1=0,r2=0,r3=0;
    if(p2==1 && p3==3)
    {
        r1+=go(p2,p3,1,i+1);
        r1%=mod;
        r1+=go(p2,p3,3,i+1);
        r1%=mod;
        r1+=go(p2,p3,4,i+1);
        r1%=mod;
    }
    else if(p2==1 && p3==2)
    {
        r1+=go(p2,p3,1,i+1);
        r1%=mod;
        r1+=go(p2,p3,2,i+1);
        r1%=mod;
        r1+=go(p2,p3,4,i+1);
        r1%=mod;
    }
    else if(p2==3 && p3==1)
    {
        r1+=go(p2,p3,1,i+1);
        r1%=mod;
        r1+=go(p2,p3,3,i+1);
        r1%=mod;
        r1+=go(p2,p3,4,i+1);
        r1%=mod;
    }
    else if((p1==1 && p2==3 && (p3==3 || p3==4)) || (p1==1 && p2==4 && p3==3))
    {
        r1+=go(p2,p3,1,i+1);
        r1%=mod;
        r1+=go(p2,p3,3,i+1);
        r1%=mod;
        r1+=go(p2,p3,4,i+1);
        r1%=mod;
    }
    else
    {
        r1+=go(p2,p3,1,i+1);
        r1%=mod;
        r1+=go(p2,p3,2,i+1);
        r1%=mod;
        r1+=go(p2,p3,3,i+1);
        r1%=mod;
        r1+=go(p2,p3,4,i+1);
        r1%=mod;
    }
    if(r1<0) r1+=mod;
    re mem[p1][p2][p3][i]=r1;
}

int main()
{
    ios_base::sync_with_stdio(0);
    ll int i,j,x,y,m,cnt=0,k,g,flg,t,l;
    fr(i,0,4)
    {
        fr(j,0,4)
        {
            fr(k,0,4)
            {
                fr(l,0,130)
                    mem[i][j][k][l]=-1;
            }
        }
    }
    cin>>n;
    cout<<go(0,0,0,1);
}


Measured memory_bytes: 512
a,b,c,k=map(int,input().split())
ans=0

if a>0:
    if (a<k):
        ans+=a
        k-=a
    else:
        ans=k
        print(ans)
        exit()

if b>0:
    if (b<k):
        k-=b
    else:
        print(ans)
        exit()

ans+=(-1)*k
print(ans)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  double t,x;
  cin>>t>>x;
  cout<<t/x<<endl;
  return 0;
}


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

int main()
{
  int n,x;
  cin >> n >> x;
  int mm = INT_MAX;
  for(int i = 0; i < n; ++i){
    int m;
    cin >> m;
    x -= m;
    mm = min(mm, m);
  }
  cout << n + x / mm << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n,m;
int e[701][701],co[701];
bool ng;
int sz=0,st[701][2];
void dfs(int cur,int v,int tco){
    co[v]=tco;
    ++st[sz][tco];
    rep(i,n)if(e[v][i]==0&&i!=v){
        if(co[i]!=-1){
            if(co[i]==tco)ng=true;
        }
        else{
            dfs(cur,i,tco^1);
        }
    }
}
int dp[707];
int main(){
    cin>>n>>m;
    int ai,bi;
    rep(i,m){
        cin>>ai>>bi;
        --ai,--bi;
        e[ai][bi]=1;
        e[bi][ai]=1;
    }
    memset(co,-1,sizeof(co));
    rep(i,n)if(co[i]==-1){
        dfs(sz,i,0);
        if(ng){
            cout<<-1<<endl;
            return 0;
        }
        ++sz;
    }
    dp[0]=1;
    rep(i,sz)for(int j=n+1;j>=0;--j)if(dp[j]!=0){
        dp[j]=0;
        if(j+st[i][0]<=n)dp[j+st[i][0]]=1;
        if(j+st[i][1]<=n)dp[j+st[i][1]]=1;
    }
    int ans=1000100010;
    rep(i,n+1){
        if(dp[i]==1){
            ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 2176
N=int(input())
def fact(N,k):
  t=0
  c=0
  while(k**t<N):
    t=t+1
  for i in range(1,t+1):
    c+=N//(k**i)
  return c
if N%2!=0:
  print(0)
else:
  c2=fact(N//2,2)
  c5=fact(N//2,5)
  print(min(c2,c5))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll i = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll i = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll i = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll i = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
// constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

ll sz = 1e6 + 5;

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];

	set<ll> st;
	rep(i, n) st.insert(a[i]);
	unordered_map<ll, ll> ump;
	rep(i, n) ump[a[i]]++;

	VecB ok(sz, true);

	for(ll i : st){
		if (!ok[i]) continue;
		for (ll j = 2; j * i < sz; ++j){
			ok[j * i] = false;
		} 
	}

	ll ans = 0;
	rep(i, n){
		if (ok[a[i]] && ump[a[i]] == 1) ans++;
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 22504
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int n,m;
    cin >> n >> m;
    int x[n+1],y[m+1];
    cin >> x[0] >> y[0];
    for(int i=1;i<=n;i++){
        cin >> x[i];
    }
    for(int i=1;i<=m;i++){
        cin >> y[i];
    }
    sort(x,x+n+1);
    sort(y,y+m+1);
    if(x[n]>=y[0]){
        cout << "War" << endl;
    }else{
        cout << "No War" << endl;
    }
}


Measured memory_bytes: 256
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N = getInput()[0];
a_i = getInput()
ret = 0

for i in range(1, N+1):
    if not i % 2 == 0:
        ret += a_i.pop(a_i.index(max(a_i)))
    else:
        ret -= a_i.pop(a_i.index(max(a_i)))
print(ret)

Measured memory_bytes: 3060
import sys
A, B = [int(x) for x in input().split()]

ans_A = 0
ans_B = 0
for i in range(1500):
  ans_A = (i*8//100)
  ans_B = (i//10)
  if(ans_A==A)and(ans_B==B):
    print(i)
    sys.exit()
print(-1)

Measured memory_bytes: 9000
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for (auto &&i : x) {
        cin >> i;
    }

    ll ans = INF64;
    if (binary_search(ALL(x), 0)) {
        K--;
    } else {
        x.emplace_back(0);
        SORT(x);
    }
    int start = lower_bound(ALL(x), 0) - x.begin();
    if (start == 0) {
        ans = x[K];
    } else if (start == x.size() - 1) {
        ans = abs(x[x.size() - 1 - K]);
    } else {
        REP(i, x.size()) {
            if (x.size() <= i + K)
                break;
            if (i <= start && start <= K + i) {
                int minus = abs(x[i]);
                int plus  = x[i + K];
                ll sum    = min(minus, plus) * 2 + max(minus, plus);
                chmin(ans, sum);
            }
        }
    }
    print(ans);

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define PI 3.14159265359

int kaibun(string num){
    if(num.size() == 1){
        return 0;
    }else{
        rep(i, (num.size() / 2)){
            if(num[i] != num[num.size() - i - 1]){
                return 0;
            }
        }
        return 1;
    }
}


int main(){
    int a, b; cin >> a >> b;
    int result = 0;
    repr(i, a, b+1){
        string tmp = to_string(i);
        result += kaibun(tmp);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<map>
using namespace std;
typedef long long int ll;

int h[100000];


int n;
int m;

bool live[100000];

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		live[i] = true;
		scanf("%d",h+i);
	}
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		if(h[a-1]<=h[b-1]) live[a-1] = false;
		if(h[a-1]>=h[b-1]) live[b-1] = false;
	}
	int ans = 0;
	for(int i=0;i<n;i++) if(live[i]) ans++;
	printf("%d\n",ans);
}


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

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

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main(void){
    ll a, b;
    cin>>a>>b;
    ll c=gcd(a, b);
    map<ll, ll>  mp=prime_factor(c);
    ll ans=mp.size()+1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/*input 
9
1 3 6 13 15 18 19 29 31
10
1
1 9
*/

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

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);

int N, L, Q;
vi x;
vpi q;
vector<vi> jump;
vi suc;

int query(int a, int b) {
	if (a == b) return 0;
	F0Rd(i, sz(jump)) {
		if (jump[i][a] < b) return (1 << i) + query(jump[i][a], b);
	}
	return 1;
}

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

	cin >> N;
	x.pb(0);
	suc.pb(0);
	FOR(i, 1, N + 1) {
		x.pb(0); cin >> x[i];
		suc.pb(0);
	}
	cin >> L >> Q;
	F0R(i, Q) {
		pi z; cin >> z.f >> z.s;
		if (z.f < z.s) q.pb(z);
		else q.pb({z.s, z.f});
	}

	FOR(i, 1, N + 1) {
		suc[i] = ub(all(x), x[i] + L) - beg(x) - 1;
	}

	jump.pb(vi(sz(x)));

	FOR(i, 1, N + 1) {
		jump[0][i] = suc[i];
	}

	for(int i = 1; (1 << i) <= sz(x); i++) {
		jump.pb(vi(sz(x)));
		F0R(j, sz(jump[i])) {
			if (jump[i - 1][j] >= sz(jump[i - 1])) continue;
			jump[i][j] = jump[i - 1][jump[i - 1][j]];
		}
	}

	/*F0R(i, sz(jump)) {
		F0R(j, sz(jump[i])) cout << jump[i][j] << " ";
		cout << '\n';
	}*/

	F0R(i, sz(q)) {
		cout << query(q[i].f, q[i].s) << '\n';
	}
}


Measured memory_bytes: 9072
import java.util.*

fun main(args : Array<String>) {
    val (n, x, y) = readLine()!!.split(' ').map(String::toInt)
    val q = ArrayDeque<Int>()
    val r = IntArray(n + 1) { -1 }
    val s = IntArray(n)
    for (i in 1..n) {
        q.add(i)
        r[i] = 0
        while (q.isNotEmpty()) {
            val v = q.remove()
            val d = r[v]
            if (v != 1 && r[v - 1] == -1) {
                q.add(v - 1)
                r[v - 1] = d + 1
            }
            if (v != n && r[v + 1] == -1) {
                q.add(v + 1)
                r[v + 1] = d + 1
            }
            if (v == x && r[y] == -1) {
                q.add(y)
                r[y] = d + 1
            }
            if (v == y && r[x] == -1) {
                q.add(x)
                r[x] = d + 1
            }
        }
        for (j in 1..n) {
            s[r[j]]++
            r[j] = -1
        }
    }
    for (i in 1 until n) {
        println(s[i] shr 1)
    }
}


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

using namespace std;

int main(){
    int N,Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<int> L(Q);
    vector<int> R(Q);
    for (int i=0; i< Q; i++) {
        cin >> L[i] >> R[i];
    }
    vector<int> AC(N);
    for (int i=0; i<N; i++){
        if (S[i-1] == 'A' && S[i] == 'C') {
            AC[i] = AC[i-1] + 1;
        }
        else {
            AC[i] = AC[i-1];
        }
    }
    for (int i = 0; i< Q; i++) {
        cout << AC[R[i]-1] - AC[L[i]-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> A;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        A.push_back(tmp);
    }
    sort(A.begin(), A.end());

    vector<int> two;
    two.push_back(1);
    for(int i=1; i<31; i++) two.push_back(two[i-1] << 1);

    bool already[200000] = {};
    int ans = 0;
    map<int,int> a;
    for(int i=N-1; i>=0; i--){
        if(already[i]) continue;
        already[i] = true;
        int t = *(upper_bound(two.begin(), two.end(), A[i]));
        auto itr = lower_bound(A.begin(), A.end(), t-A[i]);
        itr += a[*itr];
        if(*itr+A[i] == t){
            if(already[itr-A.begin()] == false){
                ans++;
                already[itr-A.begin()] = true;
                a[*itr]++;
            }
            itr++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5108
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
vi ans;
int n;
//mask showing the bits in range currently in use
void solve(int a, int b, int s, int e, int mask){
//    cout << a << " " << b << " " << s << " " <<e << " " << mask <<endl; 
    int len = e - s+1;
    if(len == 2){
        ans[s] = mask & a;
        ans[e] = mask & b;
        return;
    }

    int i = 0;
    FOR(bi , n){
        if((b & (1 << bi)) != (a & (1 << bi)) && (mask & (1 << bi))){
           i = bi; 
           break;
        }
    }
 //   debug(i);
    //different index is i
    mask ^= (1 << i);
    int mid = s + (len/2) - 1;
    solve(a, (a ^ (mask & -mask)), s,mid, mask);
    solve((a ^ (mask & -mask)),b,  mid + 1, e, mask);

    if((b & (1 << i)))
    for(int j = mid +1; j <= e; j++){
        ans[j] += (1 << i); 
    }
    if((a & (1 << i)))
    for(int j = s; j <= mid; j++){
        ans[j] += (1 << i); 
    }
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n;
    int a, b;cin >> a >> b;
    int diff = 0;
    for(int bi = 0; bi < n; bi++){
        if((b & (1  << bi)) != (a & (1 << bi))){
            diff++;
        }
    }
    if((diff & 1) == 0){
        cout << "NO" <<endl;
        return 0;
    }
    cout << "YES" <<endl;
    ans.resize((1 << n));
    solve(a, b, 0, (1 << n) -1, (1 << n) -1);

    for(int x: ans)cout << x << " ";
}



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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int plan1 = A * N, plan2 = B;
  if (plan1 <= plan2) {
    cout << plan1 << endl;
  }
  else {
    cout << plan2 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int i=0; i<N; i++){
        cin >> B[i];
    }
    int total;
    int max = 0;
    for(int i=1; i<=N; i++){
        total=0;
        for(int a=0; a<=N-i; a++){
            total = total + A[a];
        }
        for(int b=N-i; b<N; b++){
            total = total + B[b];
        }
        if(max < total){
            max = total;
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx; //rope
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[100005] = {}, c[100005] = {};
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], c[i] = a[i];
  	//for (int i = 1; i <= n; i++) cout << a[i] << ' '; cout << '\n';
    sort(c + 1, c + n + 1);
  	if (n <= 328) {
        vector<int> b;
        for (int i = 1; i <= n; i++) for (int j = i; j <= n; j++) {
            vector<int> e;
            for (int k = i; k <= j; k++) e.push_back(a[k]);
            sort(e.begin(), e.end());
            b.push_back(e[e.size() / 2]);
        }
        sort(b.begin(), b.end());
        cout << b[b.size() / 2] << '\n';
      	return 0;
    }
    int l = 0, r = n;
    while (l + 1 < r) {
        int m = (l + r) >> 1, d = 0;
      	ll z = 0;
      	ordered_set<pii> s; s.insert({0, 0});
        for (int i = 1; i <= n; i++) {	
            if (a[i] >= c[m]) d++;
            else d--;	
          	s.insert({d, i});
          	z += s.order_of_key({d, i});
        }
      	//cout << m << ' ' << c[m] << ' ' << z << '\n';
      	if (z > 1ll * n * (n + 1) / 4) l = m;
      	else r = m;
    }
  	cout << c[l] << '\n';
}


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

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

    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    
    if(m1!=m2) cout << 1 << endl;
    else cout << 0 << endl;
    
}


Measured memory_bytes: 256
n,m = list(map(int,input().split()))
ans = [0,0]
p_list = [0]*(n+1)
ac = [0]*(n+1)
for i in range(m):
    ps = input().split()
    p = int(ps[0])
    s = ps[1]
    if s=='AC' and ac[p]==0:
        ans[0] += 1
        ans[1] += p_list[p]
        ac[p] += 1
    else:
        if ac[p]==0:
            p_list[p] += 1
print(*ans, sep=' ')

Measured memory_bytes: 10428