akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>

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

int main() {
  std::priority_queue<int> q;
  std::string com;
  int key;

  while (1) {
    std::cin >> com;
    if (com == "insert") {
      std::cin >> key;
      q.push(key);
    } else if (com == "extract") {
      std::cout << q.top() << '\n';
      q.pop();
    } else {
      break;
    }
  }
  return 0;
}



Measured memory_bytes: 7080
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        int d = sc.nextInt();
        int g = sc.nextInt();
        int[] p = new int[d];
        int[] c = new int[d];
        int result = Integer.MAX_VALUE;
        for (int i = 0; i < d; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        for (int bit = 0; bit < 1 << d; bit++) {
            int sum = 0;
            int count = 0;
            for (int i = 0; i < d; i++) {
                if ((bit & 1 << i) > 0) {
                    sum += 100 * (i + 1) * p[i] + c[i];
                    count += p[i];
                }
            }
            if (sum < g) {
                for (int j = d - 1; j >= 0; j--) {
                    if ((bit & 1 << j) > 0) continue;
                    for (int k = 0; k < p[j]; k++) {
                        if (sum >= g) {
                            break;
                        }
                        sum += 100 * (j + 1);
                        count++;
                    }
                }
            }
            result = Math.min(result, count);
        }
        System.out.println(result);
    }

}


Measured memory_bytes: 23764
def main():
    import sys
    readline = sys.stdin.readline

    INF = 10 ** 8

    H, N = map(int, readline().split())

    dp = [INF] * (H + 1)
    dp[0] = 0

    for _ in range(N):
        A, B = map(int, readline().split())
        for h in range(H):
            dp[min(H, h + A)] = min(dp[min(H, h + A)], dp[h] + B)

    print(dp[H])


if __name__ == '__main__':
    main()


Measured memory_bytes: 40688
N, K, Q = (int(x) for x in input().split())
H = [K] * N
a = [input() for y in range(Q)]
A = [int(y) for y in a]

for i in A:
    H[i-1] += 1
for j in range(0, N):
    H[j] -= Q
    if H[j] > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 18060
#include<cstdio>
#include<algorithm>
#define int long long
using namespace std;
const int e=10000000000000000;
int k,n,a[100];
signed main()
{
	scanf("%lld",&k);
	n=k/e+bool(k%e);
	if(n<3)n=2;
	for(int i=1;i<=n;i++)a[i]=n-1;
	int tot=0;
	while(tot<k)
	{
		sort(a+1,a+1+n);
		int buf=-1;
		for(int i=1;i<=n;i++)
			if(a[i]==a[1])buf++;
			else break;
		
		buf=a[1]-buf+1;
		if(a[1]+buf*n>e+1000)buf-=(a[1]+buf*n-e-1000)/n;
		while(a[1]+buf*n>e+1000)buf--;
		if(tot+buf>k)buf=k-tot;
		a[1]+=buf*n;
		for(int i=2;i<=n;i++)a[i]-=buf;
		tot+=buf;
	}
	printf("%lld\n",n);
	for(int i=1;i<=n;i++)printf("%lld ",a[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

int main(){
    int k = 0;
    std::string s;
    int size = 0;

    std::cin >> k;
    std::cin >> s;

    size = s.size();

    if(size <= k){
        std::cout << s << std::endl;
    }
    else if(size > k){
        for(int i = 0; i < k; i++){
            std::cout << s[i];
        }
        std::cout << "..." << std::endl;
    }
}

Measured memory_bytes: 3624
package main

import (
	"fmt"
	"strings"
)

type line struct {
	c string
}

func main() {
	var n int
	n = 1
	// fmt.Scan(&n)

	lines := []line{}
	for i := 0; i < n; i++ {
		l := line{}
		fmt.Scan(&l.c)
		lines = append(lines, l)
	}
	// fmt.Println(lines)

	test := func(lines []line) string {
		for _, l := range lines {
			if strings.Contains("aiueo", l.c) {
				return "vowel"
			}
		}
		return "consonant"
	}

	fmt.Println(test(lines))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  int mi = 1001001001;
  rep(i, n){
    int a; cin >> a;
    int cnt = 0;
    while(a%2 == 0 && a > 0){
      a /= 2;
      cnt ++;
    } 
    chmin(mi, cnt);
  }

  cout << mi << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;
 
vector<int> A;
int n,m,q;
vector<int> a(60),b(60),c(60),d(60);
int ans=0;
 
void dfs(int x){
    A.push_back(x);
    if(A.size()==n){
        int tmp=0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i]) tmp+=d[i];
        }
        ans=max(ans,tmp);
        return;
    }
    for(int i=x;i<=m;i++){
        dfs(i);
        A.pop_back();
    }
}
 
int main(){
    
    cin>>n>>m>>q;
    
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;
        b[i]--;
    }
 
    
    for(int i=1;i<=m;i++){
        A.clear();
        dfs(i);
    }
 
    cout<<ans<<endl;
}


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

int main() {
	for (int i = 0; i < 81; i++) {
		cout << i / 9 + 1 << "x" << i % 9 + 1 << "=" << ((i / 9) + 1)*((i % 9) + 1) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3036
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<map>
#include<stack>
using namespace std;
int dx[] = { -1,0,0,1,-1,-1,1,1,0 };
int dy[] = { 0,1,-1,0,1,-1,1,-1,0 };
/*
int main()
{
	int r, c;
	cin >> r >> c;
	int sy, sx, gy, gx;
	vector<vector<char>>field(r,vector<char>(c));
	sy--, sx--, gy--, gx--;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> field[i][j];
		}
	}
	queue<pair<int,int>>q;
	q.push({ sx,sy });
	vector<vector<int>>d(c, vector<int> (r, -1));
	d[sx][sy] = 0;

	while (!q.empty())
	{
		pair<int, int>p = q.front;
		q.pop();
		for (int i = 0; i < 4; i++)
		{
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny] != -1 || field[nx][ny] == '#')continue;
			q.push({ nx,ny });
			d[nx][ny] = d[p.first][p.second] + 1;
		}
	}

	cout << d[gx][gy] << endl;
}*/


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

	sort(a.begin(), a.end(), greater<int>());

	int alice = 0, bob = 0, x = 0;

	for (int i = 0; i < n; i++)
	{
		if (x % 2 == 0)
		{
			alice += a[i];
			x += 1;
		}
		else if (x % 2 ==1)
		{
			bob += a[i];
			x += 1;
		}
	}

	int ans = 0;
	ans = alice - bob;
	cout << ans << endl;


}



Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
using namespace std;
int a[2001][2001][11];
int main(){
     
        int t[31] = { 0 };
        int n;
        for (int i = 0; i < 28; i++){
            cin >> n;
            t[n] =  1 ;
        }
         
        for (int i = 1; i<31; i++){
            if  ( t[i] == 0 ){
                cout << i << endl;
            }
        }
    }

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll a, b, h;
	ll ans = 0;

	cin >> a >> b >> h;

	ans = (a + b) * h / 2;

	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    R = int(input())
    G = int(input())

    print(G + (G - R))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
	int q,l,r,a[100005],b[100005]={};
	cin>>q;
	a[2]=1;
	a[3]=1;
	b[3]=1;
	for(int i=4;i<=100000;i++){
		for(int j=2;j<=sqrt(i);j++){
			if(i%j==0){
				a[i]=-1;
			}
		}
		a[i]++;
		if(a[i]==1 && a[(i+1)/2]==1){
			b[i]+=b[i-1]+1;
		}
		else
		{
			b[i]+=b[i-1];
		}
		
	}
	for(int i=0;i<q;i++){
		cin>>l>>r;
		cout<<b[r]-b[l-1]<<endl;
	}
  return(0);
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define popcnt __builtin_popcount
#define all(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
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;}
template<class T> T gcd(T a, T b){return b?GCD(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/GCD(a,b);}

int main(){
    int n,m; cin >> n >> m;
    vint k(n);
    vector<vint> a(n,vint(m));
    rep(i,n){
        cin >> k[i];
        rep(j,k[i]){
            cin >> a[i][j];
            --a[i][j];
        }
    }

    int flag = (1 << m+1)-1;

    rep(i,n){
        int bit = 0;
        rep(j,k[i]){
            bit |= 1 << a[i][j];
        }
        flag &= bit;
    }

    cout << popcnt(flag) << endl;

    return 0;
}


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

typedef long long ll;

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    vector<int> hito_num;
    vector<int> hito_sum;

    int before_style = s[0]; 
    int tmp_num = 1;
    int tmp_sum = 1;
    hito_num.push_back(0);
    hito_sum.push_back(0);

    for(int i = 1; i < n; i++)
    {
        if (s[i] != before_style){
            if(before_style == '1'){
                hito_num.push_back(tmp_num);
                hito_sum.push_back(tmp_sum);
            }
            before_style = s[i];
            tmp_num = 0;
        }
        tmp_num++;
        tmp_sum++;
    }
    hito_sum.push_back(tmp_sum);
    
    // for(int i = 0; i < hito_num.size(); i++)
    // {
    //     cout << hito_num[i] << " ";
    // }
    // cout << endl;
    // for(int i = 0; i < hito_sum.size(); i++)
    // {
    //     cout << hito_sum[i] << " ";
    // }

    int ans = 0;
    if ((k + 1)>= hito_sum.size()) ans = hito_sum[hito_sum.size()-1];     
    for(int i = 0; i + k < hito_sum.size(); i++)
    {
        ans = max(ans, hito_sum[i + k] - hito_sum[i] + hito_num[i]);
    }
    
    cout << ans << endl;

}


Measured memory_bytes: 1020
#include <iostream>
#include <string>

int main(void) {
    int n;
    std::cin >> n;
    std::string s;
    int a_times = 0;
    int u_times = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> s;
        if (s == "A") {
            a_times++;
        } else if (s == "Un") {
            u_times++;
        }

        if (u_times > a_times) {
            std::cout << "NO" << std::endl;
            return 0;
        }
    }
    if (u_times != a_times) {
        std::cout << "NO" << std::endl;
        return 0;
    }
    std::cout << "YES" << std::endl;

    return 0;
}

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

int main()
{
    int n, m, l, i, j, k;
    int A[100][100];
    int B[100][100];
    long C[100][100];
    
    cin >> n >> m >> l;
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            cin >> A[i][j];
        }
        for(k = 0; k < l; k++) C[i][k] = 0;
    }

    for(j = 0; j < m; j++){
        for(k = 0; k < l; k++){
            cin >> B[j][k];
            for(i = 0; i < n; i++){
                C[i][k] = C[i][k] + A[i][j] * B[j][k];
            }
        }
    }

    for(i = 0; i < n; i++){
        for(k = 0; k < l - 1; k++){
            cout << C[i][k] << " ";
        }
        cout << C[i][l - 1] << endl;
    }

    return 0;
}

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

int main(){
    string t;
    cin>>t;
    int n=t.size();
    rep(i,n)if(t[i]=='?')t[i]='D';
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct BiconectedGraph{
  typedef pair<int,int> P;
  vector<vector<int> > G,C,T;
  vector<int> ord,low,belong;
  vector<P> B;
  int n;
  BiconectedGraph(){}
  BiconectedGraph(int n):n(n){
    G.clear();
    C.clear();
    T.clear();
    G.resize(n);
    C.resize(n);
    T.resize(n);
  }
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  void input(int m,int offset){
    int a,b;
    for(int i=0;i<m;i++){
      cin>>a>>b;
      add_edge(a+offset,b+offset);
    }
  }
  
  bool is_bridge(int u,int v){
    if(ord[u]>ord[v]) swap(u,v);
    return ord[u]<low[v];
  }
  
  void dfs(int u,int p,int &k){
    ord[u]=low[u]=k;
    ++k;
    for(int v:G[u]){
      if(v==p) continue;
      if(ord[v]>=0){
	low[u]=min(low[u],ord[v]);
      }else{
	dfs(v,u,k);
	low[u]=min(low[u],low[v]);
      }
      if(is_bridge(u,v)) B.push_back(P(u,v));
    }
  }
  
  void fill_component(int c,int u){
    C[c].push_back(u);
    belong[u]=c;
    for(int v:G[u]){
      if(belong[v]>=0||is_bridge(u,v)) continue;
      fill_component(c,v);
    }
  }
  
  void add_component(int u,int &k){
    if(belong[u]>=0) return;
    fill_component(k++,u);
  }
  
  int build(){
    int k=0;
    ord.clear();
    low.clear();
    belong.clear();
    ord.resize(n,-1);
    low.resize(n);
    belong.resize(n,-1);
    for(int u=0;u<n;u++){
      if(ord[u]>=0) continue;
      dfs(u,-1,k);
    }
    k=0;
    for(int i=0;i<(int)B.size();i++){
      add_component(B[i].first,k);
      add_component(B[i].second,k);
    }
    add_component(0,k);
    for(int i=0;i<(int)B.size();i++){
      int u=belong[B[i].first],v=belong[B[i].second];
      T[u].push_back(v);
      T[v].push_back(u);
    }
    return k;
  }
};
//END CUT HERE

signed main(){
  int v,e;
  cin>>v>>e;
  BiconectedGraph bcc(v);
  bcc.input(e,0);
  bcc.build();
  typedef pair<int,int> P;
  vector<P> B=bcc.B;
  for(P &p:B) if(p.first>p.second) swap(p.first,p.second);
  sort(B.begin(),B.end());
  for(P p:B) cout<<p.first<<" "<<p.second<<endl;
  return 0;
}

/*
  verified on 2017/10/15
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B&lang=jp
*/

Measured memory_bytes: 5832
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  vector<int> H(n); for(auto& h:H) cin>>h;
  vector<int> dp(n);
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    dp[i] = 1e9+10;
    for (int j = max(0, i-k); j < i; j++) {
      dp[i] = min(dp[i], dp[j] + abs(H[i]-H[j]));
    }
  }
  cout << dp[n-1] << endl;

  return 0;
}


Measured memory_bytes: 1024
n=int(input())
l=list(map(int,input().split()))
cnt=0

for i in range(1,100+1):
    flag =True
    for j in range(n):
        if flag==True and l[j]>=i:
            cnt+=1
            flag=False
        elif flag==False and l[j]>=i:
            continue
        else:
            flag=True
print(cnt)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
#define endl '\n'
#ifndef YDK
#define eprintf(...)
#endif
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr const int INF  = 0x3f3f3f3f;
constexpr const i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr const int MOD  = int(1e9) + 7;
// }}}

// Library {{{

// }}}


signed main()
{
    int N, D;
    cin >> N >> D;

    i64 p[15][15];
    rep(i, 0, N) {
        rep(j, 0, D) {
            cin >> p[i][j];
        }
    }

    auto sqr = [](i64 n) { return n * n; };

    auto ok = [](i64 n) {
        for (i64 i = 0; i * i <= n; ++i) {
            if(i*i == n) return true;
        }
        return false;
    };

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            i64 sum = 0;
            for (int k = 0; k < D; ++k) { sum += sqr(p[i][k] - p[j][k]); }
            eprintf("%lld\n", sum);
            if (ok(sum)) ++ans;
        }
    }

    cout << (ans) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 105

enum DIR{
	North,
	East,
	South,
	West,
};

struct Info{
	bool operator<(const struct Info &arg) const{

		return num > arg.num;
	}

	int color,num;
};

int N,H,W;
int table[SIZE][SIZE];
Info info[SIZE*SIZE];


int main(){

	scanf("%d %d",&H,&W);
	scanf("%d",&N);

	for(int i = 0; i < H; i++){
		for(int k = 0; k < W; k++){

			table[i][k] = -1;
		}
	}

	for(int i = 0; i < N; i++){

		info[i].color = i+1;
		scanf("%d",&info[i].num);
	}
	sort(info,info+N);


	int row = 0,col = 0;
	DIR dir = South;

	for(int i = 0; i < N; i++){
		//printf("info[%d].color:%d num:%d\n",i,info[i].color,info[i].num);
		for(int k = 0; k < info[i].num; k++){
			//printf("row:%d col:%d color:%d\n",row,col,info[i].color);
			table[row][col] = info[i].color;

			switch(dir){
			case North:
				if(row == 0 || table[row-1][col] != -1){

					col--;
					dir = West;

				}else{

					row--;
				}
				break;
			case East:
				if(col == W-1 || table[row][col+1] != -1){

					row--;
					dir = North;
				}else{

					col++;
				}
				break;
			case South:
				if(row == H-1 || table[row+1][col] != -1){

					col++;
					dir = East;
				}else{

					row++;;
				}
				break;
			case West:
				if(col == 0 || table[row][col-1] != -1){

					row++;
					dir = South;
				}else{

					col--;
				}
				break;
			}
		}
	}

	for(row = 0; row < H; row++){

		printf("%d",table[row][0]);
		for(col = 1; col < W; col++){

			printf(" %d",table[row][col]);
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 3768
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
    	cin >> v[i];
    }
    int res = 0;
    for (int i = 0; i < n; i += 2) {
    	if (v[i] % 2 == 1) {
    		res++;
    	}
    }
    cout << res << endl;
}


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

using namespace std;

deque<char> d;
bool revers=false;

int main(){
    string s;
    cin>>s;
    for(char x:s)d.push_back(x);
    int Q;
    cin>>Q;
    for(int i=0;i<Q;i++){
        int T;
        cin>>T;
        if(T==1)revers=!revers;
        if(T==2){
            int F;
            char ch;
            cin>>F>>ch;
            if(!revers&&F==1)d.push_front(ch);
            else if(!revers&&F==2)d.push_back(ch);
            else if(revers&&F==2)d.push_front(ch);
            else if(revers&&F==1)d.push_back(ch);
        }
    }
    if(!revers)
    for(int i=0;i<d.size();i++)cout<<d[i];
    else for(int i=d.size()-1;i>=0;i--)cout<<d[i];
 return 0;   
}

Measured memory_bytes: 1024
h,w,m=map(int,input().split())
a=[[] for i in range(m)]
g=[0 for i in range(h)]
r=[0 for i in range(w)]

for i in range(m):
    x,y=map(int,input().split())
    a[i].append(x)
    a[i].append(y)
    g[x-1]+=1
    r[y-1]+=1
G=[0 for i in range(h)]
R=[0 for i in range(w)]
d=max(g)
e=max(r)
for i in range(h):
    if g[i]==d:
        G[i]=1
for i in range(w):
    if r[i]==e:
        R[i]=1
f=0
for i in range(m):
    p=0
    q=0
    x=a[i][0]
    y=a[i][1]
    if G[x-1]==1:
        p=1
    if R[y-1]==1:
        q=1


    if p==q==1:
        f+=1
v=1
if f!=G.count(1)*R.count(1):
    v=0
ans=max(g)+max(r)
print(ans if v==0 else ans-1)


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

const long long int MOD = 1000000007;

int main() {
    long long int N,a=1,b=1,c=2,ans;
    cin >> N;
    for (int i = 0; i < N; i++) {
        a *= 10;
        b *= 8;
        c *= 9;
        a %= MOD;
        b %= MOD;
        c %= MOD;
    }
    ans = (a + b - c) % MOD;
    if (ans < 0) {
        ans += MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

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

  int cnt = 0, ans = 0;
	while(cnt < N) {
		ans++;


    int ret = 0, val = ans;
  	while(val % 100 == 0) {
  		val /= 100;
  		ret++;
  	}

		if(ret == D) cnt++;
	}

  cout << ans << endl;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int64_t pcount = 0, mcount = 0;//p,a[0]を負から始めるm,a[0]を正から始める
  int sump = 0, summ = 0;
  for (int i = 0; i < n; i++) {
    sump += a[i];
    summ += a[i];
    if(i % 2 == 0) {
      if(summ >= 0) {
        mcount += 1 + summ;
        summ = -1;
      }
      if(sump <= 0) {
        pcount += 1 - sump;
        sump = 1;
      }
    }else {//添え字奇数
      if(summ <= 0) {
        mcount += 1 - summ;
        summ = 1;
      }
      if(sump >= 0) {
        pcount += 1 + sump;
        sump = -1;
      }
    }
  }
  cout << min(pcount, mcount);
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N, A[10005];
const int M = 1000000007;
map<int, int> mm;

map<int, int> pf(int n) {
	map<int, int> r;
	for (; n % 2 == 0; n /= 2) r[2]++;
	for (int i = 3; i <= n / i; i += 2)
		for (; n % i == 0; n /= i) r[i]++;
	if (n > 2) r[n]++;
	return r;
}

int exp_mod(int a, int b) {
	int r = 1ll;
	a %= M;
	b %= (M - 1);
	while (b) {
		if (b & 1ll) r = r * a % M;
		a = a * a % M;
		b >>= 1ll;
	}
	return r;
}

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) {
		auto r = pf(A[i]);
		for (auto j : r)
			mm[j.first] = max(mm[j.first], j.second);
	}
	int r = 1, s = 0;
	for (auto i : mm)
		r = r * exp_mod(i.first, i.second) % M;
	for (int i = 1; i <= N; i++)
		s += r * exp_mod(A[i], M - 2) % M, s %= M;
	cout << s << '\n';
}


Measured memory_bytes: 1024
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int count = 0;
		for (int i=0; i<n; i++) {
			if(isPrime(stdIn.nextInt()))
				count++;
		}
		System.out.println(count);
	}

	static boolean isPrime(int x){
		for (int i=2; i<=Math.pow(x,0.5); i++) {
			if(x%i == 0)
				return false;
		}
		return x!=1;
	}
}

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

signed main() {
    int N; cin >> N;
    vector<int> a(N), b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    
    vector<int> aa(N), bb(N);
    int ans = 0;
    rep(k, 29) {
        int mod = 1 << (k + 1);
        rep(i, N) {
            aa[i] = a[i] % mod;
            bb[i] = b[i] % mod;
        }
        
        sort(bb.begin(), bb.end());
        int sum = 0;
        rep(i, N) {
            {
                int l = (1 << k) - aa[i], r = 2 * (1 << k) - aa[i];
                sum += lower_bound(bb.begin(), bb.end(), r) - lower_bound(bb.begin(), bb.end(), l);
            }
            {
                int l = 3 * (1 << k) - aa[i], r = 4 * (1 << k) - aa[i];
                sum += lower_bound(bb.begin(), bb.end(), r) - lower_bound(bb.begin(), bb.end(), l);
            }
        }
        ans |= (sum & 1) << k;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<ll> diff;
	for (auto i = 0; i < N; ++i)
	{
		ll A;
		cin >> A;
		diff.push_back(A);
	}
	for (auto i = 0; i < N; ++i)
	{
		ll B;
		cin >> B;
		diff[i] -= B;
	}

	sort(diff.begin(), diff.end());
	auto minus = 0ll;
	auto ans = 0;
	for (auto i = 0; i < N && diff[i] < 0; ++i)
	{
		minus += diff[i];
		++ans;
	}

	for (auto i = N - 1; i >= 0 && diff[i] > 0; --i)
	{
		if (minus >= 0)
		{
			break;
		}
		minus += diff[i];
		++ans;
	}

	if (minus < 0)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << ans << endl;
	}


	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n; cin >> n;
    vector<ll> v(5, 0);
    REP(i, n){
        string s;
        cin >> s;
        if(s[0]=='M') v[0]++;
        if(s[0]=='A') v[1]++;
        if(s[0]=='R') v[2]++;
        if(s[0]=='C') v[3]++;
        if(s[0]=='H') v[4]++;
    }

    ll res = 0;
    for(int i=0; i<=2; i++){
        for(int j=i+1; j<=3; j++){
            for(int k=j+1; k<=4; k++){
                res += v[i]*v[j]*v[k];
            }
        }
    }
    cout << res << endl;


}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
   cin >> a >> b ;
 if ( a == (a/2)*2 || b == (b/2)*2 ){
   cout << "Even" << endl;
 }
  else{
    cout << "Odd" << endl;
  }
  }

Measured memory_bytes: 3568
#include <iostream>

int main()
{
  int N;
  std::cin >> N;

  int ans = N;
  for (int i = N; i <= 999; i++) {
    int a = i % 10;
    int b = (i % 100) / 10;
    int c = i / 100;
    if (a == b && b == c) {
      ans = i;
      break;
    }
  }

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


Measured memory_bytes: 256
import itertools

l = [int(input()) for _ in range(5)]
order_list = list(itertools.permutations(l))

min = 10**7
for order in order_list:
    sum = 0
    for i in range(4):
        sum += order[i]
        if sum % 10 > 0:
            sum += 10 - sum % 10
    sum += order[4]

    if sum < min:
        min = sum

print(min)


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

using namespace std;

typedef long long LL;
const int N = 60;

bool mat[N][N];
int n, m, s;
LL mod;

LL pow_mod(LL x, int p){
    LL s = 1;
    while(p){
		if(p & 1) 	s = s * x % mod;
		x = x * x % mod;
		p >>= 1;
    }
    return s;
}

int query(int a, int b, int c, int d){
    printf("? %d %d %d %d\n", a, b, c, d);
    fflush(stdout);
    int ret;
    scanf("%d", &ret);
    return ret;
}

void solve(int x1, int x2, int y1, int y2, int sum){
    int area = (x2 - x1 + 1) * (y2 - y1 + 1);
    if(sum == 0 || x1 > x2 || y1 > y2)	return;
    if(area == sum){
		for(int i=x1; i<=x2; i++){
			for(int j=y1; j<=y2; j++){
				mat[i][j] = 1;
			}
		}
		return;
    }

    if(x1 == x2){
		int mid = y1 + y2 >> 1;
		int g = query(x1, y1, x2, mid);
		solve(x1, x2, y1, mid, g);
		solve(x1, x2, mid+1, y2, sum - g);
	} else if(y1 == y2){
		int mid = x1 + x2 >> 1;
		int g = query(x1, y1, mid, y2);
        solve(x1, mid, y1, y2, g);
        solve(mid+1, x2, y1, y2, sum - g);
    } else {
    	bool flag = 1;
        int mid1, mid2, g1, g2, d1, d2;

        mid1 = x1 + x2 >> 1;
        g1 = query(x1, y1, mid1, y2);
        d1 = abs(sum-g1-g1);

        if(g1 == 0 || g1 == sum){
			flag = 1;
        } else {
			mid2 = y1 + y2 >> 1;
			g2 = query(x1, y1, x2, mid2);
			d2 = abs(sum-g2-g2);
			if(d1 >= d2){
				flag = 1;
			} else {
				flag = 0;
			}
        }

        if(flag){
            solve(x1, mid1, y1, y2, g1);
            solve(mid1+1, x2, y1, y2, sum - g1);
        } else {
			solve(x1, x2, y1, mid2, g2);
			solve(x1, x2, mid2+1, y2, sum - g2);
        }
    }
}

int main(){
    while(~scanf("%d %d %d %lld", &n, &m, &s, &mod)){
        memset(mat, 0, sizeof(mat));
        solve(0, n-1, 0, m-1, s);
        LL ans = 0;
        for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				if(mat[i][j]){
					ans = ans + pow_mod(2, i * m + j) % mod;
					ans %= mod;
				}
			}
        }
        printf("! %lld\n", ans);
        fflush(stdout);
    }
	return 0;
}


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

using LL=long long;

unordered_map<LL,LL> m1;
unordered_map<LL,LL> m2;
int main() {

    LL d=0;
    while(true) {
        LL f = d*d*d*d*d;
        if (f > 16000LL* INT_MAX  || f < 16000LL* INT_MIN) {
            break;
        }
        m1[f]=d;
        m1[-f]=-d;
        m2[d]=f;
        m2[-d]=-f;
        d++;
    }
    LL x; cin>>x;
    for (auto it=m1.begin(); it!=m1.end(); it++) {
        for (auto ij=m1.begin(); ij!=m1.end(); ij++) {
            if (it->first-ij->first==x) {
                cout<<it->second<<" "<<ij->second<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,t,a,b,pos,tot,cnt,ans,f[50],z[200010],sum[200010];
struct wang
{
	ll a,b;
};
vector<wang>vx;
bool mycmp(wang x,wang y)
{
	return y.a*x.b<x.a*y.b;
}
int main()
{
	scanf("%lld%lld",&n,&t);
	for (ll i=1;i<=n;i++) {
	    scanf("%lld%lld",&a,&b);
	    b=a+b+1;
	    if (a==0) z[++cnt]=b;
	    else vx.push_back((wang){a,b});
	}
	sort(z+1,z+cnt+1);
	sort(vx.begin(),vx.end(),mycmp);
	for (ll i=1;i<=cnt;i++)
	    sum[i]=sum[i-1]+z[i];
	for (ll i=1;i<=40;i++)
	    f[i]=t+1;
	for (ll i=0;i<vx.size();i++)
		for (ll j=35;j>=0;j--)
		    if (f[j]<=t) f[j+1]=min(f[j+1],(vx[i].a+1)*f[j]+vx[i].b);
	for (ll i=0;i<=35;i++) {
		if (f[i]>t) continue;
		pos=upper_bound(sum+1,sum+cnt+1,t-f[i])-(sum+1);
		ans=max(ans,i+pos);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 7428
#include <bits/stdc++.h>
using namespace std;
/*
string multiply(string x,string y){
    string ans="";
    for(int i=0;i<x.size();i++){
        for(int j=0;j<y.size();j++){

        }
    }
}
*/
int main()
{
    int n;
    cin>>n;
    int x[n];
    priority_queue<int>pq;
    for(int i=0;i<n;i++){
        cin>>x[i];
        pq.push(x[i]);
    }
    for(int i=0;i<n;i++){
        if(x[i]==pq.top()){
            int s=pq.top();
            pq.pop();
            cout<<pq.top()<<endl;
            pq.push(s);
        }
        else
            cout<<pq.top()<<endl;
    }
    return 0;
}


Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define LL long long int
#define MOD 1000000007
 
 
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}

int main(void){
    LL a,B;
    long double b;
    cin>>a>>b;
    
    cout<<(LL)(a*b)<<endl;
    return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int32_t main() {

    int n, l; cin >> n >> l;
    
    int sm = 0;
    
    bool eaten = false;
    for(int i = 0; i < n; ++i) {
        int cur = l+i;
        if(!eaten && cur >= 0) {
            eaten = true;
        } else {
            sm += cur;
        }
    }
    if(!eaten) {
        sm -= l+n-1;
    }

    cout << sm << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define ll long long

ll a[60], b[60], c[60], d[60];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < M; i++) cin >> c[i] >> d[i];
	ll min = 0;
	int p = 0;
	for (int i = 0; i < N; i++) {
		min = mod;
		for (int j = 0; j < M; j++) {
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < min) {
				min = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				p = j;
			}
		}
		cout << p + 1 << endl;
	}
}


Measured memory_bytes: 256
n = int(input())
lidata = [list(map(int,input().split())) for _ in range(n-1)]

lians = [0]*n
for i in range(n-1):
  lians[i] += lidata[i][1]
  for j in range(i):
    if lians[j] <= lidata[i][1]:
      lians[j] = lidata[i][1]
    elif lians[j]%lidata[i][2] != 0:
      lians[j] += lidata[i][2] - lians[j]%lidata[i][2]
  lians = list(map(lambda x:x+lidata[i][0],lians[:i+1])) + lians[i+1:]
#  print(lians)
for i in range(n):
  print(lians[i])

Measured memory_bytes: 3188
#include<iostream>
#include<queue>
#include<cstdio>

using namespace std;

#define LL long long

const int N=200,_N=N+33;

const int MOD=1000000007;

int n,m,k;

int fir[_N],nxt[_N],to[_N],tote=1;

int C[_N][_N];

void prework()
{
	for(int i=0,j;i<=N;++i)
	{
		for(C[i][0]=1,j=1;j<=i;++j)
			if((C[i][j]=C[i-1][j-1]+C[i-1][j])>=MOD)
				C[i][j]-=MOD;
	}
}

int gcd(int x,int y)
{
	return y?gcd(y,x%y):x;
}

int quickpow(int x,int y)
{
	int res=1;
	for(;y;y>>=1,x=(LL)x*x%MOD)if(y&1)
		res=(LL)res*x%MOD;
	return res;
}

int ny(int x)
{
	return quickpow(x,MOD-2);
}

int polya(int n,int k)
{
	if(n==0)
		return 1;
	int res=0;
	for(int i=0;i<n;++i)
		if((res+=quickpow(k,gcd(i,n))%MOD)>=MOD)
			res-=MOD;
	return (LL)res*ny(n)%MOD;
}

int low[_N],dfn[_N],dfstime,stk[_N],tp;

int col[_N],totc,lst[_N],ed;

int ans=1;

void dfs(int u,int fa)
{
	dfn[u]=low[u]=++dfstime;stk[++tp]=u;
	for(int i=fir[u],v;i;i=nxt[i])if((v=to[i])!=fa)
	{
		if(dfn[v])
			low[u]=min(low[u],dfn[v]);
		else
		{
			dfs(v,u);
			low[u]=min(low[u],low[v]);
			if(low[v]>=dfn[u])
			{
				int o,cnt_e=0;
				ed=0;
				++totc;
				do
					col[lst[++ed]=o=stk[tp--]]=totc;
				while(o!=v);
				if(col[u]!=totc)
					col[lst[++ed]=u]=totc;
				for(int j=1;j<=ed;++j)
					for(int k=fir[lst[j]];k;k=nxt[k])
						cnt_e+=(col[to[k]]==totc);
				cnt_e>>=1;
				if(ed==1)
					ans=(LL)ans*k%MOD;
				else if(ed==cnt_e)
					ans=(LL)ans*polya(cnt_e,k)%MOD;
				else
					ans=(LL)ans*C[cnt_e+k-1][cnt_e]%MOD;
			}
		}
	}
	if(!fa)
		--tp;
}

int main()
{
	//freopen("sample","r",stdin);
	prework();
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1,u,v;i<=m;++i)
	{
		scanf("%d%d",&u,&v);
		to[++tote]=v;nxt[tote]=fir[u];fir[u]=tote;
		to[++tote]=u;nxt[tote]=fir[v];fir[v]=tote;
	}
	for(int i=1;i<=n;++i)if(!dfn[i])
		dfs(i,0);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
int n,Q;
char s[N];
class BIT{
public:
	int sum[N];
	void ins(const int &x,const int &v){
		for(int i=x;i<=n;i+=i&-i)sum[i]+=v;
	}
	int ask(const int &x)const {
		int ans=0;
		for(int i=x;i;i&=i-1)ans+=sum[i];
		return ans;
	}
}bit[26];
int main(){
	cin>>n;
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)bit[s[i]-'a'].ins(i,1);
	scanf("%d",&Q);
	while(Q--){
		int op;
		scanf("%d",&op);
		if(op==1){
			int x;char c;
			scanf("%d %c",&x,&c);
			if(s[x]==c)continue;
			bit[s[x]-'a'].ins(x,-1);
			bit[c-'a'].ins(x,1);
			s[x]=c;
		}else{
			int l,r;
			scanf("%d%d",&l,&r);
			int ans=0;
			for(int i=0;i<26;i++)ans+=bit[i].ask(r)-bit[i].ask(l-1)>0;
			printf("%d\n",ans);
		}
	}		
}


Measured memory_bytes: 51584
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

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

	int l,r,d,n;
	cin>>l>>r>>d;
	n=0;
	for (int i = l; i <r+1 ; ++i)
	{
		if(i%d==0)
			n++;
	}
	cout<<n<<endl;

	return 0;
}


Measured memory_bytes: 3596
import sys

stdin = sys.stdin

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

li = []
for i in range(5):
    li.append(int(input()))
k = int(input())
for i in range(5):
    li
if max(li)-min(li) <= k:
    print('Yay!')
else:
    print(":(")

Measured memory_bytes: 3064
/**
 * Rectangle.cpp
 * Create:20180417
 * Description:空白で区切られた２つの整数より、
 * 四角形の外周と面積を出力するプログラム。
 */
#include <iostream>

/**
 * 面積を求める
 * @param  width  横幅
 * @param  height 縦幅
 * @return        面積
 */
int area(int width, int height){
  return width * height;
}

/**
 * 外周を求める
 * @param  width  横幅
 * @param  height 縦幅
 * @return        外周
 */
int outer(int width, int height){
  return width * 2 + height * 2;
}

int main(int argc, char* argv[]){
  int width;  //横幅
  int height; //縦幅

  std::cin >> width >> height;
  std::cout << area(width, height) << " " << outer(width, height) << std::endl;

  return 0;
}


Measured memory_bytes: 3020
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include<set>
using namespace std;

int main()
{
    int s;
    cin >> s;
    int left = s/100;
    int right = s%100;
    if((left-1)*(left-12) <= 0 && (right-1)*(right-12) <= 0)cout << "AMBIGUOUS"<<endl;
    else if((left-1)*(left-12) <= 0)cout << "MMYY" << endl;
    else if((right-1)*(right-12) <= 0)cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}


Measured memory_bytes: 3044
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

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

typedef long long ll;

using namespace std;

int INF = 1e9;
const double PI=acos(-1);

int main(){
  double a,h,x;
  cin >> a >> h >> x;

  if(x >= (a*a*h)/2.){
    cout << fixed;
    cout << setprecision(7) << 180.*atan(2.*(h*a*a-x)/(a*a*a))/PI << endl;
  }
  else{
    cout << fixed;
    cout << setprecision(7) << 90-180.*atan((2.*x/(a*h*h)))/PI << endl;
  }    
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())

sum2=0
for i in range(1,n+1):
    sum1=0
    c=0
    d=i
    while i>0:
        c=i%10
        sum1+=c
        i= i//10
    if sum1>=a and  sum1<=b:
        sum2+=d    
print(sum2)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

bool same(int s[],int t[],int N){
  bool ok = true;
  REP(i,N){
    if(s[i]!=t[i]){ok = false;break;}
  }
  return ok;
}

int main(){
  int N; cin>>N;
  int p[N]; CINA(p,N);
  int q[N]; CINA(q,N);
  int a[N]; REP(i,N){a[i] = i+1;}
  ll count = 0;
  ll c1 = -1;
  ll c2 = -1;
  do{
    if(same(p,a,N)){ c1 = count; }
    if(same(q,a,N)){ c2 = count;}
    if(c1>=0 && c2>=0){break;}
    count++;
  }while(next_permutation(a,a+N));
  cout << abs(c1-c2)<<"\n";;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int s[2005],t[2005];
typedef long long ll;
ll dp[2005][2005];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&s[i]);
	for(int i=1;i<=m;i++)
		scanf("%d",&t[i]);
	int sum;
	for(int i=1;i<=n;i++){
		sum=0;
		for(int j=1;j<=m;j++){
			sum+=dp[i-1][j];
			sum%=mod;
			if(s[i]==t[j]){
				dp[i][j]=sum+1;
				dp[i][j]%=mod;
			}
			else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	ll ans=0;
		for(int j=1;j<=m;j++)
			ans+=dp[n][j],ans%=mod;
	printf("%lld\n",ans+1);
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define MAX 100000
#define INF 1<<30
using namespace std;
class Edge{
public:
  int t,w;
  Edge(){}
  Edge(int t,int w):t(t),w(w){}
};
vector<Edge>G[MAX];
int n,d[MAX];
bool vis[MAX];
int cnt;

void bfs(int s){
  for(int i=0;i<n;i++)d[i]=INF;
  queue<int>q;
  q.push(s);
  d[s]=0;
  int u;
  while(!q.empty()){
    u=q.front();q.pop();
    for(int i=0;i<G[u].size();i++){
      Edge e=G[u][i];
      if(d[e.t]==INF){
        d[e.t]=d[u]+e.w;
        q.push(e.t);
      }
    }
  }
}
void solve(){
  bfs(0);
  int maxv=0;
  int tgt=0;
  for(int i=0;i<n;i++){
    if(d[i]==INF)continue;
    if(maxv<d[i]){
      maxv=d[i];
      tgt=i;
    }
  }
  bfs(tgt);
  maxv=0;
  for(int i=0;i<n;i++){
    if(d[i]==INF)continue;
    maxv=max(maxv,d[i]);
  }
  cout<<maxv<<endl;
}
int main(){
  int s,t,w;
  cin>>n;
  for(int i=0;i<n-1;i++){
    scanf("%d%d%d",&s,&t,&w);
    G[s].push_back(Edge(t,w));
    G[t].push_back(Edge(s,w));
  }
  solve();
}

Measured memory_bytes: 9960
#include <bits/stdc++.h>
#include <unordered_map>
 
using namespace std;
 
#define endl '\n'
#define ll long long
#define int long long
const int32_t INFint = 1e9;
const ll INFll = 1e18;
#define MOD 1000000007ll
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
#define vi vector < int >
#define pii pair < int , int >
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define foreach(it,v) for( __typeof((v).begin())it = (v).begin() ; it != (v).end() ; it++ )
 
#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
#define For(i, a, b) for (ll i = a; i < b; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define all(v) v.begin(),v.end()
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define gint(a,n) for(int i=0;i<n;i++) cin>>a[i];
#define setZero(a,n) for(int i=0;i<n;i++) a[i]=0;
#define printArray(a,s,e) for(int i=s;i<e;i++) {cout << a[i] << " ";} cout << endl;
//---------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------- 
int32_t main(){fast;
	

	int t;
	// cin >> t;
	t = 1;
	while(t--){
		int n, k;
		cin >> n >> k;
		int arr[n];
		gint(arr, n);

		int dp[n];
		dp[0] = 0;
		int mn;

		for(int i=1;i<n;i++){
			mn = INT32_MAX;
			for(int j=i-1;j>=max(0ll, i - k); j--) {
				// deb2(i, j);
				mn = min(mn, (dp[j] + abs(arr[i] - arr[j])));
			}
			dp[i] = mn;
		}

		cout << dp[n-1];
	}
}







Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int R;
    cin >> R;
    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
print(math.ceil(a/(2*b+1)))











Measured memory_bytes: 27104
#include<iostream>
#include<algorithm>
#include<math.h>
#define MAX 1000000;
using namespace std;

int main()
{
	long e;
	while (cin >> e && e != 0)
	{
		int min_m = MAX;
		for (int z = 0; z * z * z <= e; z++)
		{
			int y = sqrt(e - z * z * z);
			int x = e - (z * z * z) - (y * y);
			min_m = min(min_m, x + y + z);
		}
		cout << min_m << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();

    let mut white = 0;
    for i in 0..n {
        if s[i] == '.' {
            white += 1;
        }
    }

    let mut ans = white;
    let mut cnt = 0;
    for i in 0..n {
        if s[i] == '.' {
            cnt += 1;
        }
        let po = i+1 - cnt + white-cnt;
        ans = std::cmp::min(ans, po);
    }

    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;

std::pair<std::vector<ll>, std::vector<ll>> prime_factor_decomp(ll n) {
    std::vector<ll> p, e;
    ll m = n;
    for (ll i = 2; i * i <= n; i++) {
        if (m % i != 0) continue;
        int c = 0;
        while (m % i == 0) c++, m /= i;
        p.push_back(i);
        e.push_back(c);
    }
    if (m > 1) {
        p.push_back(m);
        e.push_back(1);
    }
    return std::make_pair(p, e);
}

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

    ll n, m;
    cin >> n >> m;

    ll max_k = 0;
    auto pf = prime_factor_decomp(m);
    for (auto x : pf.second) max_k = max(max_k, x);


    vector<vector<ll>> dp(n + 1, vector<ll>(max_k + 1));
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = max_k; 0 <= j; --j) {
            if (dp[i - 1][j] == 0) continue;
            for (int k = 0; k + j <= max_k; ++k)
                (dp[i][j + k] += dp[i - 1][j]) %= MOD;
        }
    }

    ll res = 1;
    for (auto k : pf.second)
        (res *= dp[n][k]) %= MOD;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 27648
#include<stdio.h>
#include<queue>
#include<map>
using namespace std;
main()
{
    int num,b;
    queue<int> q;
    map<int,int> m;
    scanf("%d",&num);
    for(int i=0;i<num;i++)
    {
        scanf("%d",&b);
        m[b]++;
    }
    if(m.size()%2==0) printf("%d\n",m.size()-1);
    else printf("%d\n",m.size());
}


Measured memory_bytes: 4864