akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    private int n;
    private Card[] cards;

    public Main(int n, Card[] cards) {
        this.n = n;
        this.cards = cards;
    }

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

    private void bubbleSort(Card[] cards) {
        boolean flag = true;
        for (int i = 0; flag; i++) {
            flag = false;
            for (int j = n - 1; j >= i + 1; j--) {
                if (cards[j].num < cards[j - 1].num) {
                    swap(cards, j, j - 1);
                    flag = true;
                }
            }
        }
    }

    private void print(Card[] cards) {
        for (int i = 0; i < n - 1; i++) {
            System.out.print(cards[i].color);
            System.out.print(cards[i].num + " ");
        }
        System.out.print(cards[n - 1].color);
        System.out.println(cards[n - 1].num);
    }

    private void selectionSort(Card[] cards) {
        for (int i = 0; i < n; i++) {
            int mini = i;
            for (int j = i; j < n; j++) {
                if (cards[j].num < cards[mini].num) {
                    mini = j;
                }
            }
            swap(cards, i, mini);
        }
    }

    private boolean isStable(Card[] bubble, Card[] sel) {
        for (int i = 0; i < n; i++) {
            if (bubble[i].color != sel[i].color) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String[] cardsString = new String[n];
        Card[] cards = new Card[n];
        for (int i = 0; i < n; i++) {
            cardsString[i] = in.next();
            cards[i] = new Card(cardsString[i].charAt(0), Integer.parseInt(String.valueOf(cardsString[i].charAt(1))));
        }
        Main test = new Main(n, cards);
        Card[] bubble = cards.clone();
        Card[] sel = cards.clone();

        test.bubbleSort(bubble);
        test.print(bubble);
        System.out.println("Stable");

        test.selectionSort(sel);
        test.print(sel);
        if (test.isStable(bubble, sel)) {
            System.out.println("Stable");
        } else {
            System.out.println("Not stable");
        }
    }
}

class Card {
    public char color;
    public int num;

    public Card(char color, int num) {
        this.color = color;
        this.num = num;
    }
}



Measured memory_bytes: 26260
// B.

#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

typedef long long LL;
static const LL MOD = 1000000007LL;

int n;
vector<int> c;

LL solve() {
	vector<LL> memo = vector<LL>(n + 1, 1);
	vector<int> p(200001, -1);
	LL r = 1;
	int last = c[0];
	p[c[0]] = 0;
	memo[0] = r;
	for (int i = 1; i < n; ++i) {
		memo[i] = r;
		if (c[i] != last) {
			if (p[c[i]] >= 0) {
				r = (r + memo[p[c[i]]]) % MOD;
			}
			p[c[i]] = i;
		}
		memo[i] = r;
		last = c[i];
	}
	return r;
}

int main(int argc, char *argv[]) {
	cin >> n;
	c = vector<int>(n + 1, -1);
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
	}
	LL ans = solve();
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
import sys
n=int(input())
lis=[0for i in range(n)]
for i in range(2,n+1):
  ib=i
  for j in range(2,ib+1):
    while(ib%j==0):
      lis[j-1]+=1
      ib=ib//j
pat=1
for i in lis:pat*=(i+1)
print(pat%(10**9+7))

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef  vector<int> vi;
typedef  pair<int,int> ii;
typedef  pair<int,string> pis;
double   pi=3.1415926535898;
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define lp(i,n)    for(int i=0;i<int(n);i++)
#define ff(i,a,b)  for(int i=a;i<=int(b);++i)
#define fr(i,a,b)  for(int i=a;i>=int(b);i--)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define r0         return 0;
#define CC         continue;
#define bb(x)      cerr<< x <<endl;
#define F          first
#define S          second       //  __builtin_popcount;
//freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
string ys = "Yes\n";
string no = "No\n" ;
const double EPS = 1e-6;
const int inf = 1<<20;
const ll M  = 1e9+7 ;
//const int N = 100100;
//////////////////////    Hi    ^_^  hack me if you can :P

int n, m, rr ;
int a, b, c ;
int r[222];
int d[222][222];
int mem[1<<10][10];
int dp ( int msk, int l)
{
    if ( msk == 0 )
    {
        return 0;
    }
    int &ret = mem[msk][l];
    if ( ret != -1)
        return ret;
    ret = 1000000000;
    ff(i,0,rr-1)
    {
        if ( msk&(1<<i))
        {
            ret = min(ret, d[r[l]][r[i]] + dp(msk-(1<<i),i));
        }
    }
    return ret;
}
int main()
{
    cin >> n >>  m >> rr;
    ff(i,0,rr-1)
    {
        cin >> r[i];
    }
    ff(i,1,200) ff(j,1,200) d[i][j] = d[j][i] = (i!=j)*1000000000;
    ff(i,1,m)
    {
        cin >> a >> b >> c;
        d[a][b] = d[b][a] = min(d[a][b],c);
    }
    ff(k,1,n)
    {
        ff(i,1,n)
        {
            ff(j,1,n)
            {
                d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }

    int ans = 1e9;
    ms(mem,-1);
    ff(i,0,rr-1)
    {
        ans = min(ans, dp( (1<<rr)-1-(1<<i),i));
    }
    cout << ans;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, m;
    cin >> n >> m;
    vpii g(m);
    rep(i, m) cin >> g[i].first >> g[i].second;
    int l = 1, r = n;
    rep(i, m) {
        l = max(l, g[i].first);
        r = min(r, g[i].second);
    }
    int ans = max(r-l+1, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
from itertools import combinations
D, G = map(int, input().split())
G = G // 100
ns = [0] * (D + 1)
cs = [0] * (D + 1)
for i in range(1, D + 1):
    n, c = map(int, input().split())
    ns[i] = n
    cs[i] = c // 100

ans = sum(ns)
for partialsn in range(1, D + 1):
    for partials in combinations(range(1, D + 1), partialsn):
        sumn = 0
        rp = G
        for i in range(1, D + 1):
            if not i in partials:
                sumn += ns[i]
                rp -= i * ns[i] + cs[i]
        if rp > 0:
            for i in sorted(partials, reverse=True):
                n = ns[i] - 1
                if rp <= i * n:
                    n = rp // i
                    if rp % i != 0:
                        n += 1
                sumn += n
                rp -= i * n
                if rp <= 0:
                    break
        if rp <= 0:
            if sumn < ans:
                ans = sumn
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <cstdlib>
using namespace std;

int main() {
  stack<int> S;

  int a,b;
  string s;
  while(cin >> s){
    if(s[0] == '+'){
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();
      S.push(a+b);
    } else if(s[0] == '*'){
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();
      S.push(a*b);
    } else if(s[0] == '-'){
      a = S.top();
      S.pop();
      b = S.top();
      S.pop();
      S.push(b-a);
    } else {
      S.push(atoi(s.c_str()));
    }
  }
  
  cout << S.top() << endl;      
  
  return 0;
}

Measured memory_bytes: 1196
#include<algorithm>
#include<chrono>
#include<climits>
#include<numeric>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
 
#define rep(i, a, b) for(auto i = (a); i < (b); i++)
#define rrep(i, a, b) for(auto i = (a); i > (b); i--)
#define all(v) (v).begin(), (v).end()
#define print(v) {for(auto x : v) cout << x << ' '; cout << endl;}
#define printn(v, n) {for(int _i = 0; _i < n; _i++) cout << *(v + _i) << ' '; cout << endl;}
 
typedef unsigned long long ull;
typedef long long ll;
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
 
const int MAXN = 1e3 + 20;
int n;
int a[MAXN][MAXN];

int get_node(int x, int y){
	if(x > y) swap(x, y);
	return x * n + y;
}

vector<int> graph[MAXN * MAXN];
int tin[MAXN * MAXN] = {}, tout[MAXN * MAXN] = {}, t = 1;
vector<int> order;
bool dfs(int node) {
    tin[node] = t++;
    for(auto to : graph[node]) {
        if(tout[to]) continue;
        if(tin[to] || !dfs(to))
            return false;
    }
    tout[node] = t++;
    order.push_back(node);
    return true;
}
bool tp_sort() {
    for(int i = 0; i < n * n; i++) {
    	if(i / n >= i % n)
    		continue;
        if(!tin[i]) {
            bool tmp = dfs(i);
            if(!tmp) return false;
        }
    }
    return true;
}

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

    cin >> n;
    for(int i = 0; i < n; i++) {
    	for(int j = 0; j < n - 1; j++) {
    		cin >> a[i][j];
    		a[i][j]--;
    		if(j)
    			graph[get_node(i, a[i][j - 1])].push_back(get_node(i, a[i][j]));
    	}
    }
    int valid = tp_sort();
    reverse(order.begin(), order.end());
    if(!valid) {
    	cout << -1 << endl;
    	return 0;
    }

    vector<int> cur(n, 1);
    for(int i : order) {
    	int x = i / n, y = i % n;
    	int d = max(cur[x], cur[y]);
    	cur[x] = d + 1;
    	cur[y] = d + 1;
    }
    cout << *max_element(cur.begin(), cur.end()) - 1 << endl;
    //print(order);

    return 0;
}











Measured memory_bytes: 54520
#include <stdio.h>


int main(void) {

    int n;
    scanf("%d", &n);

    char *ret;
    int flg = n % 10;

    if (flg == 3) {
        ret = "bon";
    } else if (flg == 0 || flg == 1 || flg == 6 || flg == 8) {
        ret = "pon";
    } else {
        ret = "hon";
    }

    printf("%s", ret);

    return 0;
}

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

int main(){
  char s[10006];
  int n;
  int m,i;

  scanf("%d", &n);
  scanf("%s", s);

  m = strlen(s);

  for(i = 0;i < m;i++){
    if(s[i] + n > 'Z') s[i] = s[i] - 26 + n;

    else s[i] = s[i] + n;

    printf("%c", s[i]);
  }
  printf("\n");

  return 0;
}


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

int main(){
  int N;
  cin>>N;
  int F[110][10];
  ll P[110][11];
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++) cin>>F[i][j];
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++) cin>>P[i][j];
  }
  ll ans=-10e10;
  for(int i=1;i<(1<<10);i++){
    ll profit=0;
    int same[110]={0};
    for(int j=0;j<10;j++){
      if((i>>j) & 1==1){
        for(int k=0;k<N;k++){
          if(F[k][j]) same[k]++;
        }
      }
    }

    for(int k=0;k<N;k++){
      profit+=(ll)P[k][same[k]];
    }
    ans=max(ans,profit);
  }
  
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <inttypes.h>

int N;
int32_t T[114514];
int M;
int P[114514];
int32_t X[114514];

int main(void) {
	int i;
	int32_t sum = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%" SCNd32, &T[i]) != 1) return 1;
		sum += T[i];
	}
	if (scanf("%d", &M) != 1) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d%" SCNd32, &P[i], &X[i]) != 2) return 1;
	}
	for (i = 0; i < M; i++) {
		printf("%" PRId32 "\n", sum - T[P[i]] + X[i]);
	}
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long a[1000010];
int main()
{
    int n,x=1,ans=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    sort(a,a+n);
    for(int i=1;i<n;i++)
    {
        if(a[i]==a[i-1])
            x=(x+1)%2;
        else
        {
            ans+=x;
            x=1;
        }
    }
    if(x%2)
        ans++;
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007
int G[110000];
int main()
{

	int N, M;
	cin >> N >> M;

	fx(M) {
		int l, r;
		cin >> l >> r;
		G[l]++;
		G[r + 1]--;
	}
	fx(N + 2){
		G[x + 1] += G[x];
}
	int ans = 0;
	fx(N) {
		if (G[x + 1] ==M) {
			ans++;
		}

	}

	ce(ans)

    return 0;
}



Measured memory_bytes: 640
import sys
readline = sys.stdin.readline

N = int(readline())
S = list(map(lambda x: ord(x)-65, readline().strip()))

ans = 0
for i in range(N-2):
    for j in range(3):
        if S[i+j] != j:
            break
    else:
        ans += 1
print(ans)


Measured memory_bytes: 38384
import sys
import heapq
heappush = heapq.heappush
heappop = heapq.heappop
heapreplace = heapq.heapreplace
input = sys.stdin.readline

D = int(input())
cost = list(map(int, input().strip().split()))
S = [list(map(int, input().strip().split())) for _ in range(D)]
k = 5
last_held = [[-1 for i in range(26)] for _ in range(k)]
ans = [[] for _ in range(k)]
for date, daily_scores in enumerate(S):
    max_score = []
    minus_scores = []
    for state in range(k):
        minus_score = 0
        for i in range(26):
            minus_score += cost[i] * (date - last_held[state][i])

        for i in range(k-len(max_score)):
            tmp = daily_scores[i] + cost[i] * (date - last_held[state][i])
            heappush(max_score, (tmp, i, state))

        for i, daily_score in enumerate(daily_scores):
            if state == 0 and i < k:
                continue
            tmp = daily_score + cost[i] * (date - last_held[state][i])
            if max_score[0][0] < tmp:
                heapreplace(max_score, (tmp, i, state))
    if date != D-1:
        #print(max_score)
        next_last_held = []
        next_ans = []
        for score, i, state in max_score:
            next_last_held.append(last_held[state][:])
            next_last_held[-1][i] = date
            next_ans.append(ans[state][:])
            next_ans[-1].append(i+1)
        ans = next_ans
        last_held = next_last_held
    else:
        score, i, state = max(max_score)
        next_ans = ans[state][:]
        next_ans.append(i+1)
        ans = next_ans

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


Measured memory_bytes: 70572
#include <iostream>
#include <algorithm>

using namespace std;

int main(void){

  for(int i = 0 ; i < 7 ; i++){
    int a, b;
    cin >> a >> b;
    if(a < 0 && b < 0) cout << abs(b) - abs(a) << endl;
    else if(a >= 0 && b <= 0) cout << a + abs(b) << endl;
    else if(a >= 0 && b >= 0) cout << a - b << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}

int main(){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string go1 = {}, go2 = {}, back1 = {}, back2 = {};
	
	int width = tx - sx;
	int height = ty - sy;
	for(int i = 0; i < height; i++){
		go1 += 'U';
		back1 += 'D';
	}
	for(int i = 0; i < width; i++){
		go1 += 'R';
		back1 += 'L';
	}

	for(int i = 0; i < height + 2; i++){
		if(i == 0){
			go2 += 'L';
  		back2 += 'R';
		}else if(i <= height){
			go2 += 'U';
			back2 += 'D';
		}else if(i == height + 1){
			go2 += 'U';
			back2 += 'D';
		}
	}
	for(int i = 0; i < width + 2; i++){
		if(i == 0){
			go2 += 'R';
  		back2 += 'L';
		}else if(i <= width){
			go2 += 'R';
			back2 += 'L';
		}else if(i == width + 1){
			go2 += 'D';
			back2 += 'U';
		}
	}
	cout << go1 << back1 << go2 << back2 << endl;
}


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



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

   vector<int> d;

   for (int i = 1; i * i <= M; i++) {
     if (M % i == 0) {
       d.push_back(i);
       d.push_back(M / i);
     }
   }

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

   auto itr = lower_bound(d.begin(), d.end(), N);

   cout << M / *itr << endl;
 }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int N_MAX=50;
typedef long long ll;
int main()
{
  int n,a,b,m,k,t=0,i;
  ll c=1,res;
  ll v[N_MAX];
  long double s=0;
  cin >> n >> a >> b;
  for(i=0;i<n;i++)
    cin >> v[i];
  sort(v,v+n,greater<ll>());
  for(i=0;i<a;i++){
    s+=v[i];
    if(i>0&&v[i]<v[i-1])
      t=i;
  }
  s/=a;
  for(;i<n;i++)
    if(v[i]<v[t])
      break;
  m=i-t;
  k=a-t;
  for(i=1;i<=k;i++){
    c*=m+1-i;
    c/=i;
  }
  res=c;
  if(t==0)
    for(;i<=min(m,b);i++){
      c*=m+1-i;
      c/=i;
      res+=c;
    }
  cout << setprecision(10) << s << endl; 
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3768
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int main(){
    string s;
    cin >> s;
    int a = ((s[0] - '0') * 10) + (s[1] - '0');
    int b = ((s[2] - '0') * 10) + (s[3] - '0');
    bool fym , fmy;
    fym = fmy = 0;
    if(0 < b && b <13) fym = true;
    if(0 < a && a <13) fmy = true;

    if(fym){
        if(fmy) cout << "AMBIGUOUS" << endl;
        else cout << "YYMM" << endl;
    }else{
        if(fmy) cout << "MMYY" << endl;
        else cout << "NA" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

vector<pair<int,int>> vp;int N;
int dp[200099][40];

pair<int, int> find_repr(string &s) {
  int n = s.size();
  ll num = 0;
  int di = -1;

  for(int i = 0;i < n;i++) {
    if(s[i] == '.') {
      di = i;
      continue;
    }
    num = num*10 + int(s[i]-'0');
  }

  int j = (di == -1 ? 0 : n-di-1);
  for(;j < 9;j++) {
    num *= 10;
  }

  // debug(num);

  int x = -9, y = -9;
  while(num % 2 == 0) {
    x++;
    num /= 2;
  }
  while(num % 5 == 0) {
    y++;
    num /= 5;
  }

  return {x, y};

}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout << setprecision(10) << fixed;

 string s;
 cin>>N;
 rep(i, N) {
   cin >> s;
   vp.pb(find_repr(s));
 }

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

 // for(auto x : vp) {
 //   cout<<x.F<<","<<x.S<<" ";
 // }

 for(int i = vp.size()-1;i >= 0;i--) {
   dp[i][vp[i].S + 10] = 1;
   for(int j = 0;j <= 20;j++) dp[i][j] += dp[i+1][j];
 }

 ll ans = 0;
 for(int i = 0;i < vp.size();i++) {
   int x = -vp[i].F, y = -vp[i].S;
   int j = lower_bound(vp.begin(), vp.end(), mp(x , -999)) - vp.begin();
   if(x <= 0) j = i+1;
   for(int k = 10 + y;k <= 20;k++) ans += dp[j][k];
 }
 cout << ans << endl;

 return 0;
}


Measured memory_bytes: 36164
n, m = map(int, input().split(" "))
ab = [list(map(int, input().split(" "))) for _ in range(m)]

ab.sort(key=lambda x: x[1])

count = 0
before = 0
for a_i, b_i in ab:
	if before > a_i:
		continue
	before = b_i
	count += 1

print(count)

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());

    int count = 0;

    for (int i = 0; i < n; ++i) for (int j = 0; j < i; ++j) for (int k = 0; k < j; ++k) count += v[k] != v[j] && v[i] != v[j] && v[k] + v[j] > v[i];

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3644
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


n = int(input())
ans = 0
if n > 2:
    for i in range(1, n-1):
        for j in range(i + 1, n):
            for k in range(j + 1, n + 1):
                tmp = gcd(i, j)
                ans += gcd(tmp, k) * 6
if n > 1:
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            ans += gcd(i, j) * 6
ans += n*(1+n)//2
print(ans)


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

int main() {
	int64_t X, K, D;
	cin >> X >> K >> D;

	int64_t absx = abs(X);
	int64_t div = absx/D;

	if (div > K) {
		cout << absx-D*K << endl;
		return 0;
	}

	absx -= D*div;
	K -= div;

	if (K%2 == 0)
		cout << absx << endl;
	else
		cout << abs(absx-D) << endl;

	// cout << min(absx-D*div, abs(absx-D*(div+1))) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

template<class T>
T min(T a, T b) {
    return (a < b) ? a : b;
}

template<class T>
T max(T a, T b) {
    return (a > b) ? a : b;
}

int main() {
    string S;

    cin >> S;

    int cnt = 0;
    for (int i = 0; i < S.length(); i++) {
        int j = S.length() - i -1;

        if (i >= j) break;

        if (S[i] != S[j]) cnt++;
    }

    cout << cnt;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding space */
template<class T>
struct BIT{
    vector<T> d;
    BIT(size_t n):d(n+1){}
    T sum(size_t i){T s{};for(++i;i>0;i-=i&-i)s+=d[i];return s;}
    T sum(size_t i,size_t j){return i?sum(j)-sum(i-1):sum(j);}
    void add(size_t i,T x){for(++i;i<d.size();i+=i&-i)d[i]+=x;}
};
int main(){
  string s,t; cin >> s >> t;
  BIT<int> ssum(s.size()+1),tsum(t.size()+1);
  rep(i,s.size()){
    if(s[i] == 'A') ssum.add(i+1,1);
    else ssum.add(i+1,2);
  }
  rep(i,t.size()){
    if(t[i] == 'A')
      tsum.add(i+1,1);
    else
      tsum.add(i+1,2);
  }
  int q; cin >> q;
  rep(i,q){
    int a,b,c,d; cin >> a >> b >> c >> d;
    if((ssum.sum(a,b)-tsum.sum(c,d))%3 == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 1664
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
 
 
// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
 
public class Main {
    
    public static BufferedReader br;
    public static StringTokenizer sto;
    
    public static void main(String args[] ) throws Exception {
        StringBuffer str = new StringBuffer();
        PrintWriter pw=new PrintWriter(System.out);
        br = new BufferedReader(new InputStreamReader(System.in));
        int k = nextInt();


            int val = 7%k;
            for(int i=1;i<1e7;i++){
                if(val==0){
                    str.append(i);
                    break;
                }
                val = (val*10+7)%k;
                
            }
            if(val!=0){
                str.append("-1");
            }
        
        
        pw.println(str.toString());
        
        pw.close();
    }
     
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
    public static int[] arrayInt(int n) throws Exception{
       sto = new StringTokenizer(br.readLine());
       int[] newarray = new int[n];
       for(int i=0;i<n;i++){
           newarray[i] = Integer.parseInt(sto.nextToken());
       }
       return newarray;
    }
    
    public static long[] arrayLong(int n) throws Exception{
       sto = new StringTokenizer(br.readLine());
       long[] newarray = new long[n];
       for(int i=0;i<n;i++){
           newarray[i] = Long.parseLong(sto.nextToken());
       }
       return newarray;
    }
   
   
   public static double nextDouble() throws Exception{
       return Double.parseDouble(br.readLine());
   }
   
   public static long nextLong() throws Exception{
       return Long.parseLong(br.readLine());
   }
   
   
   public static int nextInt() throws Exception{
       return Integer.parseInt(br.readLine());
   }
   
}

Measured memory_bytes: 32968
package main

import "fmt"

func min(a []int) int {
	ret := 1000001
	for _, v := range a {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func max(a []int) int {
	ret := -1000001
	for _, v := range a {
		if ret < v {
			ret = v
		}
	}
	return ret
}

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	fmt.Println(min(a), max(a), sum(a))
}


Measured memory_bytes: 1736
# ABC058C - 怪文書 / Dubious Document (ARC071C)
import sys
input = sys.stdin.readline

from collections import OrderedDict
from string import ascii_lowercase


def main():
    n = int(input())
    lst = [input().rstrip() for _ in range(n)]
    cnt = OrderedDict.fromkeys(ascii_lowercase, 0)
    for i in lst[0]:
        cnt[i] += 1

    for i in lst[1:]:
        tmp = OrderedDict.fromkeys(ascii_lowercase, 0)
        for j in i:
            tmp[j] += 1
        for i in cnt.keys():
            cnt[i] = min(cnt[i], tmp[i])

    ans = ""
    for i, j in cnt.items():
        ans += i * j
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

int abso(int n){
    if(n<0) return -n;
    else return n;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int dp[n+1];
    memset(dp, 0, sizeof(dp));
    dp[2]=abso(a[1]-a[0]);
    for(int i=3;i<=n;i++){
        dp[i]=min(abso(a[i-1]-a[i-2])+dp[i-1],abso(a[i-1]-a[i-3])+dp[i-2]);
    }
    cout << dp[n];
}


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

#define range 524289
#define mod 998244353
#define eps 1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

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


int e[8] = {1,-1,1, -1, 2,2,-2,-2};
int z[8] = {2, 2,-2, -2, 1,-1,1,-1};



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){
        int n, k;
        cin>>n;
        vvi dp(n, vi(3));

        cin>>dp[0][0]>>dp[0][1]>>dp[0][2];

        for (int i = 0; i < n-1; ++i)
        {
            /* code */
            int x, y, z;
            cin>>x>>y>>z;
            dp[i+1][0] = x + max(dp[i][1], dp[i][2]);
            dp[i+1][1] = y + max(dp[i][0], dp[i][2]);
            dp[i+1][2] = z + max(dp[i][1], dp[i][0]);
        }

        cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
        return 0;

    }

}



Measured memory_bytes: 5760
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int input;
	map<int, int>m;
	vector<int>v;
	rep(i, 6) {
		cin >> input;
		m[input]++;
	}
	if (m.size() != 4) {
		cout << "NO";
		return 0;
	}
	for (auto i : m)v.push_back(i.second);
	sort(v.begin(), v.end());
	if (v[0] == 1 && v[1] == 1 && v[2] == 2 && v[3] == 2)cout << "YES";
	else cout << "NO";
}

Measured memory_bytes: 256
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
from decimal import *


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


if __name__ == '__main__':
    n =int(input())
    a = [int(i) for i in input().split()]
    max = 0
    count =0
    for i in a:
        if max <= i:
            count+=1
            max = i

    print(count)


Measured memory_bytes: 5144
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;


int main() {

    long long x ;
    cin >> x  ;

    long long tmp = 100 ;
    int ans = 0 ;

    while(tmp<x){
        tmp=floor(tmp*(1.01)) ;
        ans++ ;
       // cout << tmp << endl ;
    }

    cout << ans << endl  ;

 return 0 ;
}  


Measured memory_bytes: 3716
# [参照先] https://img.atcoder.jp/abc122/editorial.pdf
# 累積和を用いる
n, q = map(int, input().split())
s = input()  # 長さnの文字列

t = [0] * (n + 1)
# ACが出るのは2文字目から
for i in range(1, n):
    t[i + 1] = t[i] + (1 if s[i - 1:i + 1] == 'AC' else 0)
for i in range(q):
    l, r = map(int, input().split())
    print(t[r] - t[l])

# わからなくなったら図を書く
# 0 1 2 3 4 5 6 7 8  (tの添字の位置)
# 0 0 1 1 2 2 2 3 3
#  A C A C T A C G
#  1 2 3 4 5 6 7 8   (r, lは1スタート)

# 入力例
# 8 3
# ACACTACG
# 3 7
# 2 3
# 1 8

# 出力例
# 2
# 0
# 3

Measured memory_bytes: 9364
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    std::string s;
    std::string ans;
    int n;
    char ch;
    char sub;
    std::cin >> n >> s;
    for (char c : s)
    {
        ch = c + n;
        if (ch > 'Z')
        {
            sub = ch - 'Z';
            ch = 'A' + sub - 1;
        }
        ans.push_back(ch);
    }
    std::cout << ans << std::endl;
    return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll v;
  scanf("%lld", &v);

  map<ll, ll> m;
  ll i = 1;
  for (;; i++) {
    if (m[v]) {
      break;
    }
    m[v] = 1;

    // cout << v << endl;
    if (v % 2 == 0) {
      v = v / 2;
    } else {
      v = v * 3 + 1;
    }
  }
  cout << (i) << endl;
}

// 1,000,000

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

const int N = 5e5;

inline int tog_bit(int x, int mask){
	return (1<<x) ^ mask;
}

int n,q;
char s[N+5];

int ST[4*N+5];

void build(int node, int l, int r){
	if(l == r){
		ST[node] = tog_bit(s[l-1] - 'a',0);
		return;
	}
	int mid = (l+r)/2;
	build(node*2,l,mid);
	build(node*2+1,mid+1,r);
	ST[node] = ST[node*2] | ST[node*2+1];
	return;
}

void update(int node, int l, int r, int id, char x){
	if(l == r){
		ST[node] = tog_bit(x - 'a',0);
		return;
	}
	int mid = (l+r)/2;
	if(id <= mid) update(node*2,l,mid,id,x);
	else update(node*2+1,mid+1,r,id,x);
	ST[node] = ST[node*2] | ST[node*2+1];
	return;
}

int query(int node, int l, int r, int ql, int qr){
	if(l >= ql && r <= qr) return ST[node];
	if(l > qr || r < ql) return 0;
	int mid = (l+r)/2;
	return query(node*2,l,mid,ql,qr) | query(node*2+1,mid+1,r,ql,qr);
}

int get_cnt(int x){
	int ret = 0;
	for(int i=0;i<26;i++){
		if((1<<i) & x) ret++;
	}
	return ret;
}

int main(){
	scanf("%d",&n);
	scanf("%s",s);
	build(1,1,n);
	scanf("%d",&q);
	while(q--){
		int com;
		scanf("%d",&com);
		if(com == 1){
			int id;
			char ub;
			scanf("%d %c",&id,&ub);
			update(1,1,n,id,ub);
		} else {
			int l,r;
			scanf("%d %d",&l,&r);
			int ans = query(1,1,n,l,r);
			printf("%d\n",get_cnt(ans));
		}
	}
	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define reg register
#define int long long
#define maxn 200001
using namespace std;
struct node{int x, opt, id;} c[maxn];
bool cmp(node g, node h){return g.x < h.x;}
int n, a[maxn], b[maxn], ans, sum, cnt, d[maxn], w[3], t;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
signed main()
{
	n = read();
	for(int i = 1; i <= n; i++){
		a[i] = read(); b[i] = read();
		c[++cnt].x = a[i]; c[cnt].id = i; c[cnt].opt = 0;
		c[++cnt].x = b[i]; c[cnt].id = i; c[cnt].opt = 1;
	}
	sort(c + 1, c + cnt + 1, cmp);
	for(int i = 1; i <= n; i++){
		d[c[i].id]++; ans += c[i].x;
		w[c[i].opt]++; if(d[c[i].id] == 2) t = 1;
	}
	if(t == 1 || w[1] == 0 || w[0] == 0){
		cout << ans << endl; return 0;
	}
	sum = 1000000000000000000;
	for(int i = 1; i <= n; i++){
		if(c[n].id != i) sum = min(sum, ans + max(a[i], b[i]) - c[n].x);
		else sum = min(sum, ans + max(a[i], b[i]) - c[n - 1].x);
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 8832
n = int(input())
work = []
for i in range(n):
    a, b = map(int, input().split())
    work.append((b, a))
work.sort()

time = 0
for i in range(n):
    if work[i][1] + time > work[i][0]:
        print('No')
        exit()
    time += work[i][1]

print('Yes')

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;

  vector<ll> a(n);
  REP(i, n)
    cin >> a[i];

  map<ll, ll> fmap;
  REP(i, n)
    fmap[a[i]]++;
  
  bool sflag = true;
  ll ans = 1;
  if(n % 2 == 1){
    if(fmap[0] != 1)
      sflag = false;
    REP1(i, n/2+1){
      if(fmap[i*2] != 2)
        sflag = false;
      ans *= 2;
      ans %= mod;
    }
  }
  else{
    REP(i, n/2){
      if(fmap[i*2+1] != 2)
        sflag = false;
      ans *= 2;
      ans %= mod;
    }
  }

  if(sflag)
    cout << ans << endl;
  else
    cout << 0 << endl;


}


Measured memory_bytes: 6144
#[allow(dead_code)]
fn read_line(n: usize) -> String {
    let mut ss = String::new();
    for _i in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        ss.push_str(&s);
    }
    ss
}

macro_rules! parse {
    ($s:expr => $($r:tt)*) => {
        let s = $s;
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        parse!{s => $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main()
{
    parse!{
        m1: usize,
        _d1: usize,
        m2: usize,
        _d2: usize,
    }
    if m1 != m2 {
        println!("1");
    }
    else {
        println!("0");
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A[3];
  cin>>A[0]>>A[1]>>A[2];
  sort(A,A+3);
  if((A[0]==A[1]&&A[0]!=A[2])||(A[1]==A[2]&&A[1]!=A[0]))
    puts("Yes");
  else	puts("No");
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.AbstractMap;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		solve(sc, out);
		
		out.flush();
	}
	
	public static void solve(FastScanner sc, PrintWriter out){
		int n = sc.nextInt();
		int x = sc.nextInt();
		
		int[] m = new int[n];
		
		long res = 0;
		
		for(int i = 0; i < n; i++) {
			m[i] = sc.nextInt();
			x-=m[i];
			res++;
		}
		
		int min = Arrays.stream(m).min().getAsInt();
		
		while(x-min >= 0) {
			x-=min;
			res++;
		}
		
		out.println(res);
	}

	public static int gcd(int a, int b) {
		if(a < b) return gcd(b, a);
		if(b == 0) return a;
		return gcd(b, a % b);
	}
}

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 27476
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define lld long double
using namespace __gnu_pbds;
int main()
{
    fast;
    ll int x;
    cin>>x;
    if(x>=400 && x<600 )
    	cout<<"8";
    if(x>=600 && x<800 )
    	cout<<"7";
    if(x>=800 && x<1000 )
    	cout<<"6";
    if(x>=1000 && x<1200 )
    	cout<<"5";
    if(x>=1200 && x<1400 )
    	cout<<"4";
    if(x>=1400 && x<1600 )
    	cout<<"3";
    if(x>=1600 && x<1800 )
    	cout<<"2";
    if(x>=1800 && x<2000 )
    	cout<<"1";
}
    


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(LL N, LL M){
	LL ret = 1;
	LL upper = M / N;
	for (int u = upper; u >= 2; u--) {
		LL res = M - N * u;
		if (res % u == 0) {
			ret = u;
			break;
		}
	}
	cout << ret << endl;
}


int main(){	
	LL M;
	LL N;
	scanf("%lld",&N);
	scanf("%lld",&M);
	solve(N, M);
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<bitset>
#include<map>
using namespace std;

#define LL long long
#define DB double
#define MOD 1000000007
#define Pr pair<DB,int>
#define X first
#define Y second
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}

int add(int a,int b){return (a+b>=MOD)?a+b-MOD:a+b;}
int dec(int a,int b){return (a-b<0)?a-b+MOD:a-b;}
int mul(int a,int b){return 1LL*a*b%MOD;}
LL pabs(int x){
    return (x<0)?-x:x;
}

int T;
int n,m,pre;

struct Matrix{
    int ma[3][3];
    Matrix(){mem(ma,0);}
};

void init(Matrix &K)
{
	K.ma[0][0]=1;//c->c
    K.ma[1][0]=1;K.ma[1][1]=1;//b(x+1)->bx+b
    K.ma[2][0]=1;K.ma[2][1]=2;K.ma[2][2]=1;//cx^2->cx^2+2cx+c
}

Matrix mul(Matrix A,Matrix B)
{
	Matrix C;
    for(int k=0;k<3;k++)
	   for(int i=0;i<3;i++)
            for(int j=0;j<3;j++)
            C.ma[i][j]=add(C.ma[i][j],mul(A.ma[i][k],B.ma[k][j]));
	return C;
}

Matrix fs_pow(Matrix A,LL k)
{
	Matrix B;
	for(int i=0;i<3;i++)
    B.ma[i][i]=1;
	while(k) {
        if(k&1) B=mul(B,A);
        A=mul(A,A);
        k>>=1;
    }
    return B;
}

int main()
{
    pre=1;
    n=read(),m=read();
    Matrix A,B,Fc;
	init(A);B=A;
    B.ma[0][2]++,B.ma[1][2]++,B.ma[2][2]++;
	Fc.ma[0][2]=1;
    for(int i=1;i<=m;i++){
        int x=read();
        Fc=mul(Fc,fs_pow(B,x-pre));
        Fc=mul(Fc,A);
        pre=x+1;
    }
    Fc=mul(Fc,fs_pow(B,n-pre));
    printf("%d\n",add(Fc.ma[0][0],add(Fc.ma[0][1],Fc.ma[0][2])));
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, h, m;

int main(){
	cin >> n;
	REP(i, n){
		scanf("%d:%d", &h, &m);
		double s = (double)h * 30.0 + (double)m*0.5, l = (double)m * 6.0;
		double d = max(l, s) - min(l, s);
		if (d > 180)d = 360 - d;
		if (d < 30.0)cout << "alert\n";
		else if (d < 90.0)cout << "warning\n";
		else cout << "safe\n";
	}
}

Measured memory_bytes: 1204