akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;
const ll MOD = 998244353;

int main() {
    string S;
    cin >> S;
    int n = S.size();
    vector<int> a(n + 1, 0);
    int l = 0, r = 0;
    while (r < n) {
        while (r < n && S[r] == '<') r++;
        //cout << "< l=" << l << " r=" << r << endl;
        rep(i, r - l + 1) a[l + i] = i;
        l = r;
        while (r < n && S[r] == '>') r++;
        //cout << "> l=" << l << " r=" << r << endl;
        rep(i, r - l + 1) a[l + i] = max(a[l + i], r - l - i);
        l = r;
    }
    ll ans = 0;
    rep(i, n + 1) {
        //cout << a[i] << " ";
        ans += a[i];
    }
    //cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 2820
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
 
public class Main {
 
    public static void main(String[] args) {
 
 
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            String inputData = reader.readLine();
 
            BigDecimal r = new BigDecimal(inputData);
            BigDecimal bdPI = new BigDecimal(3.14159265358979323846d);
 
            BigDecimal area = r.pow(2).multiply(bdPI).setScale(6, BigDecimal.ROUND_HALF_UP);
            BigDecimal round = bdPI.multiply(r).multiply(new BigDecimal(2)).setScale(6, BigDecimal.ROUND_HALF_UP);
 
            System.out.println(area.toPlainString() + " " + round.toPlainString());
 
        } catch (IOException e) {
            e.printStackTrace();
        }
 
    }
 
}

Measured memory_bytes: 24692
S = input()
stack = ""
resLis = []

for i in range(len(S)):
  stack = stack + S[i]
  if len(resLis) >= 1:
    if stack == resLis[len(resLis)-1]:
      continue
  resLis.append(stack)
  stack = ""
print(len(resLis))

Measured memory_bytes: 8296
#include<iostream>
#include<string>
#include<iomanip>
#include<sstream>
#include<regex>

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

using namespace std;

int main()
{
    ostringstream oss;
    int n,m,a=0,b,x,y,sum=0;
    int flag = 0;
    char c;
    string s;
    cin >> n >> m;
    if(n>1) a = 1;
    rep(i,n-1) a  *= 10;
    oss << a;
    s = oss.str();
    rep(i,m){
        cin >> x >> c;
        if(x == 1 && c == '0' && n != 1 || n < x){
            flag = 1;
            break;
        }
        if(s[x-1] == '0' || s[x-1] == c){
            s[x-1] = c; 
        }else if(x==1&&s[x-1]=='1'){
             s[x-1] = c;
        }else{
            flag = 1;
            break;
        }
    }
    if(!flag) cout << s << endl;
    if(flag) cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <limits>

using namespace std;

int main(){
  int N,R;
  scanf("%d %d", &N, &R);

  if(N>=10){
    printf("%d\n",R);
  }else{
    printf("%d\n",R+100*(10-N));
  }
  return 0;
}

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

class Dice{
public:
  int face[6];
  Dice(){}

  void roll_x(){ roll(0,3,5,2);}
  void roll_y(){ roll(0,1,5,4);}
  void roll_z(){ roll(1,2,4,3);}
  void roll(int i, int j, int k, int l){
    int t = face[i]; face[i] = face[j]; face[j] = face[k]; face[k] = face[l]; face[l] = t;
  }
};

bool check(Dice d1,Dice d2){
  for (int i = 0; i < 6; i++){
    if (d1.face[i] != d2.face[i]) return false;
  }
  return true;
}

bool rotation(Dice d1, Dice d2){
  for(int j = 0; j < 6; j++){
    for(int k = 0; k < 4; k++){
      if(check(d1, d2)) return true;
      d1.roll_z();
    }

    if(check(d1,d2)) return true;
    if (j == 2) d1.roll_y();
    else d1.roll_x();
  }
  return false;
}

int main(void) {
  Dice d1,d2;
  for(int i = 0; i < 6; i++){
    cin >> d1.face[i];
  }
  for(int i = 0; i < 6; i++){
    cin >> d2.face[i];
  }

  if ( rotation(d1, d2)) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

int store[100007];

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) scanf("%d", &store[i]);

    bool flg = true;
    for (int i = N-1; i >= 1; i--) {
        if (store[i-1] > store[i]) store[i-1]--;
        if (store[i-1] > store[i]) {flg = false; break;}
        assert(store[i-1] <= store[i]);
    }

    if (flg)  cout << "Yes\n";
    else cout << "No\n";
}


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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

bool comp(pair<string, int> a, pair<string, int> b) 
{
    if(a.fi < b.fi) {
        return true;
    } else if(a.fi > b.fi) {
        return false;
    } else {
        if(a.se > b.se) {
            return true;
        } else {
            return false;
        }
    }
}

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

    vector<pair<string, int> > v;
    map<string, int> ans;

    irep(i, n) {
        string s; cin >> s;
        int p; cin >> p;
        v.push_back({s,p});
        string mp = s + to_string(p);
        ans[mp] = i+1;
    }
    
    sort(v.begin(), v.end(), comp);

    irep(i, n) {
        cout << ans[v[i].fi + to_string(v[i].se)] << endl;
    }

    return 0;
} /*atcoder*/


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

struct UF
{
	vector<ll> par; // 親のインデックスを記憶する配列
	vector<ll> sz; // サイズを記憶する。
	vector<ll> rank;
	vector<vector<int>> edge;
	// 初期化
	UF(int n):par(n),sz(n),rank(n),edge(n){
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;rank[i] = 0;
		}
	}
	// 親を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
			sz[y] += sz[x];
			REP(i,edge[x].size())edge[y].PB(edge[x][i]);
		}
		else{
			par[y] = x;
			sz[x] += sz[y];
			REP(i,edge[y].size())edge[x].PB(edge[y][i]);
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
	// 素の集合のサイズを求める
	int size(int n){return sz[find(n)];}
};

int main(){
	
	ll n,m;cin >> n >> m;
	vector<ll> v(n);
	REP(i,n)cin >> v[i];
	vector<pair<ll,pair<ll,ll>>> edge;
	REP(i,m){
		ll a,b,c;cin >> a >> b >> c;
		a--;b--;
		edge.EB(c,MP(a,b));
	}
	
	sort(ALL(edge));
	UF uf(n);
	REP(i,n)uf.sz[i] = v[i];
	
	REP(i,edge.size()){
		int a = edge[i].SE.FI;
		int b = edge[i].SE.SE;
		ll cost = edge[i].FI;
		//cout << "edge " << a << " " << b << " " << cost << endl;
		if(!uf.same(a,b)){
			uf.unite(a,b);
			if(cost <= uf.sz[uf.find(a)]) {
				vector<int> tmp;
				int par = uf.find(a);
				REP(j,uf.edge[par].size()){
					int id = uf.edge[par][j];
					if(edge[id].FI > uf.sz[par])tmp.PB(id);
				}
				uf.edge[par] = tmp;
			}
		}
		if(cost > uf.sz[uf.find(a)]){
			uf.edge[uf.find(a)].PB(i);
			//cout << "   seica" << endl;
		}
	}
	
	//SHOW1d(uf.edge[uf.find(0)],uf.edge[uf.find(0)].size());
	cout << uf.edge[uf.find(0)].size() << endl;
		
	
	return 0;
}


Measured memory_bytes: 12784
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#define ll long long
using namespace std;
int n,a[100086];
ll ans;
bool vis[100086];
inline ll read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
ll get()
{
    ll sum=0,tmp=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i])
        {
            sum+=a[i];if(sum<=0){tmp+=abs(sum)+1;sum=1;}
        }else{
            sum+=a[i];if(sum>=0){tmp+=sum+1;sum=-1;}
        }
    }
    return tmp;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)a[i]=read();
    for(int i=1;i<=n;i++)vis[i]=i%2;
    ans=get();
    for(int i=1;i<=n;i++)vis[i]=1-i%2;
    ans=min(ans,get());
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll t[1001] = {};
ll a[1001] = {};
int main() {
	ll n; cin >> n;
	ll curT = 1, curA = 1;
	repe(i, 1, n)cin >> t[i] >> a[i];

	repe(i, 1, n) {
		ll p = max(curT / t[i] + ((curT % t[i]) ? 1 : 0), curA / a[i] + ((curA % a[i]) ? 1 : 0));
		curT = t[i] * p;
		curA = a[i] * p;
		//cout << curT << " " << curA << endl;
	}
	cout << curT + curA << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 101
#define INFTY 1000000
 
int G[MAX][MAX];
int d[MAX];
 
void Dijkstra(int);
 
int main(void){
  int i, j, k, n, v, u, c;
 
  scanf("%d", &n);
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      G[i][j] = INFTY;
    }
  }
 
  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    for(j=0; j<k; j++){
      scanf("%d%d", &v, &c);
      G[u][v] = c;
    }
  }
 
  Dijkstra(n);
 
  return 0;
}
 
void Dijkstra(int n){
  int i, j, k, min;
  int d[MAX], c[MAX];
 
  d[0] = 0;
  for(i=1; i<n; i++){
    d[i] = INFTY;
    c[i] = 0;
  }
 
  while(1){
    min = INFTY;
 
    for(i=0; i<n; i++){
      if(c[i] != 1 && d[i] < min){
        j = i;
        min = d[i];
      }
    }
 
    if(min == INFTY) break;
 
    c[j] = 1;
    for(k=0; k<n; k++){
      if(c[k] != 1 && d[j] + G[j][k] < d[k]) d[k] = d[j] + G[j][k];
    }
  }
 
  for(i=0; i<n; i++) printf("%d %d\n", i, d[i]);
 
  return;
}

Measured memory_bytes: 640
def resolve():
    N = int(input())
    A = list(map(int, input().split()))

    mp = dict()
    ans = 0
    for i in range(N):
        x = i - A[i]
        ans += mp.get(x, 0)
        y = A[i] + i
        mp[y] = mp.get(y, 0) + 1
    print(ans)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 40536
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	int ans = n;
	rep(i, n+1) {
		int now = 0;
		int tmp = i;
		while (tmp > 0) {
			now += tmp % 6; tmp /= 6;
		}
		tmp = n - i;
		while (tmp > 0) {
			now += tmp % 9; tmp /= 9;
		}
		chmin(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 2001;

int n;
bitset <N * N> b;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    b.set(0);
    int sum = 0;
    for(int i = 0 ; i < n ; i++){
        int x;
        cin >> x;
        sum += x;
        b |= b << x;
    }
    for(int i = (sum + 1) / 2 ; ; i++){
        if(b[i]) finish(i);
    }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    ll n; cin>>n; 
    bool flag = true;
    vector <ll> a;
    ll count = 0, id = 1;
    loop(n){
        ll x;
        cin>>x;
        if(x==id){
            a.push_back(x);
            id++;
        }
        else count++;
    }

    ll p = a.size();
    for(ll i = 0; i<p; i++){
        if(a[i]!=i+1){flag = false; break;}
    }

    if(flag && p!=0)cout<<count;
    else cout<<-1;
    return 0;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;


ull E = 1000000007;
const double pi = 3.14159265359;

int main() {
    int AB, BC, CA;
    cin >> AB >> BC >> CA;
    cout << AB * BC / 2 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        int a ,b,c;
        Scanner input =  new Scanner(System.in);
        a=input.nextInt();
        b=input.nextInt();
        c=input.nextInt();

        if(a+b+c==17){
            System.out.println("YES");
        }
        else {
            System.out.println("NO");
        }
    }
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m; cin >> n >> m;
	long long days{};
	for(int i{}; i < m; i++)
	{
		long long a; cin >> a;
		days += a;
	}
	auto leftover = n - days;
	if (leftover < 0)
		leftover = -1;
	cout << leftover;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cassert>
#include<iomanip>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define PI 3.14159265358979
#define MAX 45
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long double ld;
int n,m;
ld p[MAX];
ld area[MAX][MAX][MAX];//area[start point][last point][new point] := the area
ld dp[MAX][MAX][MAX];//dp[start point][last point][the number] := maximum area

double getArea(int i,int j)
{
  assert(i < n && j < n);
  return sin((p[j]-p[i])*2*PI)/2.0;//S = (b*c*sinA)/2,in this case, b = c = 1
}

void init_area()
{
  rep(i,n)//start point
    {
      REP(j,i,n)//last point
	{
	  REP(k,j,n)//new point
	    {
	      area[i][j][k] = getArea(i,j)+getArea(j,k)+getArea(k,i);
	    }
	}
    }
}

int main()
{
  while(cin >> n >> m,n|m)
    {
      rep(i,n)cin >> p[i];

      init_area();

      rep(i,MAX)rep(j,MAX)rep(k,MAX)dp[i][j][k] = -inf;
      rep(i,MAX)rep(j,MAX)dp[i][j][2] = 0;
      ld ans = -inf;
      rep(sp,n)
	{
	  REP(cnt,2,m)
	    {
	      REP(lp,sp+1,n)
		{
		  REP(np,lp+1,n)
		    {
		      if(dp[sp][lp][cnt] == -inf)continue;

		      dp[sp][np][cnt+1] = max(dp[sp][np][cnt+1],
					      dp[sp][lp][cnt]+area[sp][lp][np]);
	
		     
		      if(cnt+1 <= m)
			ans = max(ans,dp[sp][np][cnt+1]);  
		    }
		}
	    }
	}

      cout << setiosflags(ios::fixed) << setprecision(6) << ans << endl;

    }
  return 0;
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
int tab[MAXN];

int sum(int n){
	int res=0;
	while(n){
		res+=n%10;
		n/=10;
	}
	return res;
}

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int a,b,n,res=0;
    cin >> n >> a >> b;
    for(int i=1;i<=n;i++)
		if(sum(i)>=a && sum(i)<=b)
			res+=i;
	cout << res;
}


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

#define endl "\n"
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define all(x) (x).begin(),(x).end()
#define rect return 0
#define pause cout << endl; system("pause")
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(x) (int)(x).size()
#define Pi acos(-1.0)
#define bitcount __builtin_popcountll

#define TupleGet(name, index) std::get<(index)>(name)
#define FOR(a, b, c) for(int (a) = (b); (a) < (c); ++(a))
#define FORs(a, b, c) for(int (a) = (b); (a) <= (c); ++(a))
#define revFOR(a, b, c) for(int (a) = (b); (a) > (c); --(a))
#define revFORs(a, b, c) for(int (a) = (b); (a) >= (c); --(a))
#define foreach(it, a) for(auto it = (a).begin(); it != (a).end(); it++)

using namespace std;

// *** TYPEDEF'S, CONSTANTS AND FUNCTIONS *** //
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tii;
typedef vector<vector<int> > vvi;

/* |T| |I| |P| |S|
@ string abc = "abcdefghijklmnopqrstuvwxyz";
@ 'char' - 'a' ::: порядковый номер латинской буквы
@ 'digit' - '0' or 'digit' - 48 ::: (char) ---> (int)
@ 'A' = dec 65 'Z' = dec 90
  'a' = dec 97 'z' = dec 122
  '0' = dec 48 '9' = dec 57
@ Если страдает скорость ввода:
1) ios::sync_with_stdio(0);
   cin.tie(0);
2) юзать сканф
@ для стринга перевод i-того символа в другой регистр: a[i] = char (a[i] +- 32)  :::  32 == 'a' - 'A'
@ int n (m знаков) :::  n[1] = n / 10^(m-1) ; n[m] = n % 10 ; n[m-1] = (n % 100)/10 ; n[m-2] = (n % 1000)/100...
@ cout << fixed << setprecision(n) ::: n знаков после запятой, без "fixed" - всего n знаков
@ abs(x-y) < EPS ::: равентсво вещественных чисел x и y по точности EPS
@ x + EPS < y  или  x - EPS < y ::: сравнение больше-меньше для вещественных чисел по точности EPS
@ если цифру можешь записать из головы - так и пиши в программе, иначе - пиши ФОРМУЛУ
@ «экспонента» - целое число, показывающее, на сколько надо сдвинуть десятичную запятую в числе ::: 123e2 = 12300 , 123e-4 = 0.0123
@ если задача плохо решается при нумерации с единицы, иногда оказывается намного проще перейти к нумерации с нуля.
  Особенно задачах, где явно надо делить на равные части.
@ while(cin >>)  |||  while (getline(cin, )) ::: считывание, пока даются данные
@ ctrl+Z ::: конец файла в консоли
@ Глобальные массивы, чтобы не было ошибок; размер брать с запасом
@ Количество цифр N числа X в b-ичной записи, N = floor[ log[b](X) ] + 1
@ ios::sync_with_stdio(0); //ввод
@ cin.tie(0); cout.tie(0); //могут быть проблемы в интерактивных задачах (частый ввод-вывод)
*/

void solve() {
    int n, c;
    cin >> n >> c;

    vi a(n);
    for (int i = 0; i < n; i++)cin >> a[i];

    int ans = 1;
    n = max(0, n - c);
    ans += ((n + c - 2) / (c - 1));

    cout << ans;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int mod=(1e9)+7;
int n;
int d[25][25];
int dp[1<<21];
void update(int &x,int y) {
	x+=y; if (x>=mod) x-=mod;
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); int x;
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++) read(d[i][j]);
	dp[0]=1;
	for (int t=0;t<(1<<n);t++) {
		x=1;
		for (int i=1;i<=n;i++)
			if (t&(1<<(i-1))) x++;
		for (int i=1;i<=n;i++) {
			if (t&(1<<(i-1))) continue;
			if (d[x][i]) update(dp[t+(1<<(i-1))],dp[t]);
		}
	}
	printf("%d\n",dp[(1<<n)-1]);
	return 0;
}

Measured memory_bytes: 8448
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    P_ls.sort(reverse=True)
    diff = -1
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X-i):
                    rst = i
    print(rst)

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

int main () {
  int N,K;
  cin >> N >> K;
  vector <int> test(N);
  for (int i = 0; i < N;i++) cin >> test.at(i);
  for (int i = 0; i < N-K;i++){
    if (test.at(i) < test.at(i+K)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
} 

Measured memory_bytes: 3964
#include<bits/stdc++.h>
using namespace std;
#define ff                first
#define br                "\n"
#define ss                second
#define int               long long
#define pb                push_back
#define ps(x,y)           fixed<<setprecision(y)<<x
#define mk(arr,n,type)    type *arr=new type(n);
#define w(x)              int x; cin>>x; while(x--)
#define FOR(i,a,b)        for(int i=(a);i<(b);i++)
#define ROF(i,a,b)        for(int i=(a);i>=(b);i--)
#define so(a,n)           sort(a,a+n)
#define rso(a,n)          sort(a,a+n),reverse(a,a+n)
const                     int maxn=100010;
#define s(l)              s.length()

void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input1.txt", "r", stdin);
  freopen("outp1.txt", "w", stdout);
#endif
}
void solve()
{

  string s;cin>>s;
  s+='S';
  int r=0,cu=0;
  for(int i=0;i<4;i++)
  {
    if(s[i]=='R')r++;
    else
    {
      cu=max(cu,r);
      r=0;
    }
  }
  cout<<cu;

}
int32_t main()
{
  c_p_c();
  //w(t)
  solve();

}




Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, Q;
llint p[100005], pinv[100005];
llint a[100005], b[100005];
set<llint> S;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> Q;
	for(int i = 1; i <= n; i++) p[i] = pinv[i] = i;
	for(int i = 1; i <= Q; i++) cin >> a[i] >> b[i];
	S.insert(1);
	
	llint u, v;
	for(int i = 0; i <= Q; i++){
		swap(p[a[i]], p[b[i]]);
		swap(pinv[p[a[i]]], pinv[p[b[i]]]);
		llint x = pinv[1];
		if(x > 1) S.insert(p[x-1]);
		if(x < n) S.insert(p[x+1]);
	}
	cout << S.size() << endl;
	
	return 0;
}

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

typedef long long int ll;

ll dp[100010],pre[100010];
const int mod = 1e9+7;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	ll A,B;
	cin>>n>>A>>B;
	if(A>B)	swap(A,B);
	vector<ll> v(n+1,-4e18);
	for(int i=1;i<=n;i++)
		cin>>v[i];
	dp[0]=1;
	pre[0]=1;
	int from=0;
	for(int i=1;i<=n;i++){
		int to=upper_bound(v.begin(),v.end(),v[i]-B)-v.begin()-1;
		if(from<=to){
			dp[i]=(dp[i]+pre[to])%mod;
			if(from!=0)
				dp[i]=(dp[i]+mod-pre[from-1])%mod;
		}
		if(i!=n&&v[i+1]-v[i-1]<A)	dp[i]=0;
		pre[i]=(pre[i-1]+dp[i])%mod;
		if(v[i]-v[i-1]<A)	from=i-1;
	}
	ll ans=0;
	for(int i=from;i<=n;i++){
		if(i!=0&&i!=n&&v[i+1]-v[i-1]<A);
		else
			ans=(ans+dp[i])%mod;
	}
	cout<<ans<<endl;
}


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

int main() {
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;
    string u; cin >> u;

    if (u == s)
        a--;
    else
        b--;

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;
#define MAXX 20010
typedef long long ll;



//int par[MAXX];
//初期化
void init(int n,int par[]){
  REP(i,n){
    par[i] = i;
  }
}
//根をもとめる
int root(int x, int par[]){
  if(par[x] == x){
    return x;
  }
  else{
    return par[x] = root(par[x],par);
  }
}

bool same(int x,int y,int par[]){
  if(root(x,par) == root(y,par)){
    return true;
  }
  else{
    return false;
  }
}

void unite(int x,int y, int par[]){
  x = root(x,par);
  y = root(y,par);
  if(x == y){
    return;
  }
  par[x] = y;
}

int main(){
  int n,k,l;
  cin >> n >> k >> l;
  int par[n+1];
  int parx[n+1];
  init(n+1,par);
  init(n+1,parx);
  REP(i,k){
    int p,q;
    cin >> p >> q;
    unite(p,q,par);
  }
  REP(i,n+1){
    root(i,par);
  }
  /*
  REP(i,n+1){
    cout << par[i] << endl;
    }*/
  REP(i,l){
    int p,q;
    cin >> p >> q;
    unite(p,q,parx);
  }
  REP(i,n+1){
    root(i,parx);
  }

  vector <P> pair;
  for(int i = 0;i < n+1;i++){
    
    pair.pb(mk(par[i],parx[i]));
    
  }
  sort(pair.begin(),pair.end());
  for(int i = 1;i < n+1;i++){
    int x = par[i];
    int y = parx[i];
    //iterator j = lower_bound(pair.begin(),pair.end(), make_pair(x,y)) ;
    //cout << j << endl;
    /*
    while(x != pair[j].first || y != pair[j].second){
      j++;
    }
    */
    //iterator k = upper_bound(pair.begin(),pair.end(), make_pair(x,y));
    /*
    while(x == pair[k].first && y == pair[k].second){
      k++;
      }*/
    cout << upper_bound(pair.begin(),pair.end(), make_pair(x,y)) - lower_bound(pair.begin(),pair.end(), make_pair(x,y)) << " " ;
  }
  cout << endl;
  /*
  int num[n+1]={0};
  for(int i = 1;i < n+1;i++){
    for(int j = i; j < n+1;j++){
      if(par[i] == par[j] && parx[i] == parx[j]){
	num[i]++;
	num[j]++;
      }
    }
  }
  for(int i = 1;i < n+1;i++)
    cout << num[i]-1 << " ";
  cout << endl;
  */
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename Monoid>
class SegmentTree {
	using F = std::function<Monoid(Monoid, Monoid)>;
	const F f;
	const Monoid M1;
	
	std::vector<Monoid> seg;
	int sz;
	
	bool built;
	
	private:
	void set(int k, const Monoid x) {
		built = false;
		seg[k + sz] = x;
	}
	void build() {
		if(built) return;
		built = true;
		for(int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}
	
	public:
	SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
		sz = 1;
		built = true;
		while(sz < n) sz <<= 1;
		seg.assign(sz * 2, M1);
	}
	SegmentTree(std::vector<Monoid> array, const F f, const Monoid &M1) : f(f), M1(M1) {
		sz = 1;
		built = true;
		while(sz < array.size()) sz <<= 1;
		seg.assign(sz * 2, M1);
		update(array);
	}
	void add(int k, Monoid x) {
		k += sz;
		seg[k] = f(seg[k], x);
		
		while(k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}
	bool update(int k, Monoid x) {
		if(k > sz) return false;		
		k += sz;
		seg[k] = x;
		while(k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
		return true;
	}
	bool update(std::vector<Monoid> array) {
		if(array.size() > sz) return false;
		for(int i = 0; i < array.size(); i++) set(i , array[i]);
		build();
		return true;
	}
	Monoid get(int a, int b) {
		build();
		Monoid L = M1, R = M1;
		for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if(a & 1) L = f(L, seg[a++]);
			if(b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}
	Monoid operator[](const int k) const {
		return seg[k + sz];
	}
	std::pair<int, i64> solve(std::vector<i64>& latte) {
		int ok = 0, ng = latte.size(), all = get(0, latte.size()).second;
		int half = (all & 1 ? all / 2 + 1 : all / 2);
		while(std::abs(ok - ng) > 1) {
			int mid = (ok + ng) >> 1;
			
			int ret = get(0, mid).second;
			if(ret < half) ok = mid;
			else ng = mid;
		}
		auto L = get(0, ok);
		auto R = get(ok, latte.size());
		
		i64 ans = (latte[ok] * L.second - L.first) + (R.first - latte[ok] * R.second);
		return {latte[ok], ans};
	}
};

int main() {
	int q; scanf("%d", &q);
	
	
	std::vector<i64> type(q), a(q), b(q), latte;
	for(int i = 0; i < q; i++) {
		scanf("%lld", &type[i]);
		
		if(type[i] == 1) {
			scanf("%lld%lld", &a[i], &b[i]);
			
			latte.push_back(a[i]);
		}
	}
	sort(begin(latte), end(latte));
	latte.erase(unique(begin(latte), end(latte)), end(latte));
	
	i64 sum = 0;
	using P = std::pair<i64, i64>;
	auto f = [](P a, P b) { return P{a.first + b.first, a.second + b.second}; };
	SegmentTree<P> seg(latte.size(), f, {0, 0});
	for(int i = 0; i < q; i++) {
		if(type[i] == 1) {
			int k = lower_bound(begin(latte), end(latte), a[i]) - begin(latte);
			
			seg.add(k, {a[i], 1});
			sum += b[i];
		} else {
			auto p = seg.solve(latte);
			
			printf("%d %lld\n", p.first, p.second + sum);
		}
	}
	return 0;
}


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

int H, W;

int main() {
    while (1) {
        
        cin >> H >> W;
        if (H == 0 && W == 0) {
            return 0;
        } else {
            if (H == 1) {
                for (int i = 0; i < W; i++) {
                    cout << "#";
                }
                cout << endl;
            } else if (W == 1){
                for (int i = 0; i < H; i++) {
                    cout << "#";
                    cout << endl;
                }
            } else {
                for (int i = 0; i < W; i++) {
                    cout << "#";
                }
                cout << endl;
                for (int n = 0; n < H - 2; n++) {
                    cout << "#";
                    
                    for (int i = 0; i < W - 2; i++) {
                        cout << ".";
                    }
                    cout << "#";
                    cout << endl;
                }
                for (int i = 0; i < W; i++) {
                    cout << "#";
                }
                cout << endl;
            }
           
            cout << endl;
        }
        
    }
}



Measured memory_bytes: 3080
def nCr(n, r, mod):
    res=1
    fac=1
    for i in range(r):
        res *= n-i
        res %= mod
        fac *= i+1
        fac %= mod
    return res*pow(fac, mod-2, mod)%mod

n, a, b=map(int,input().split())
MOD = 10**9+7
ans = pow(2,n,MOD)-1
ans -= nCr(n,a, MOD)
ans -= nCr(n,b, MOD)

print(ans%MOD)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int , input().split()))

import fractions
lcm = 1
prevlcm = 1
ans = 0
for i in range(n):
    ai = a[i]
    lcm = ai * lcm // fractions.gcd(ai, lcm)
    if prevlcm == lcm:
        ans = ans + (lcm // ai)
    else:
        ans = ans * (lcm // prevlcm) + (lcm // ai)
    #print(i, lcm, ans)
    prevlcm = lcm

print(ans % (10**9 + 7))

Measured memory_bytes: 69352
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int N = sc.nextInt();

		int cnt = 0;
		for (int i = 0; i*R <= N ; i++) {
			for (int j = 0; j*G <= N-i*R; j++) {

				if ((N-i*R-j*G)%B == 0) {
					cnt++;
				}
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21588
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = Integer.parseInt(scanner.nextLine());
		String[] inputs = scanner.nextLine().split(" ");
		int[] nums = new int[inputs.length];
		for (int i = 0; i < inputs.length; i++) {
			nums[i] = Integer.parseInt(inputs[i]) + 100;
		}
		int ave = (int) ((double) Arrays.stream(nums).sum() / n + 0.5d);
		int sum = 0;
		for (int num: nums) {
			sum += (num - ave) * (num - ave);
		}
		System.out.println(sum);
	}
}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// Segment Tree {{{
template <typename T>
class SegTree {
 private:
    int _n;
    T _init_val;
    std::vector<T> _data;
    std::function<T(T, T)> _f;

    T _query(int a, int b, int k, int l, int r) {
        // [a b)と[l r]が交差しない
        if (r <= a || b <= l) return _init_val;

        // [a b)が[l r]を含む
        if (a <= l && r <= b) return _data[k];

        T vl = _query(a, b, k*2+1, l, (l+r)/2);
        T vr = _query(a, b, k*2+2, (l+r)/2, r);

        return _f(vl, vr);
    }

 public:
    SegTree(int n, T init_val, std::function<T(T, T)> f) {
        _init_val = init_val;
        _n = 1;
        _f = f;

        while (_n < n)
            _n *= 2;
        _data.resize(2 * _n, init_val);
    }

    T get(int k) {
        return _data[k + _n - 1];
    }

    void update(int k, T a) {
        k += _n-1;
        _data[k] = a;
        while (k > 0) {
            k = (k-1)/2;
            _data[k] = _f(_data[k*2+1], _data[k*2+2]);
        }
    }

    // [a b)の範囲でfを適用
    T query(int a, int b) {
        return _query(a, b, 0, 0, _n);
    }

    // 先頭からチェックし，はじめてxを満たしたインデックス
    int lower_bound(T x) {
        return _lower_bound(x, 0);
    }

    int _lower_bound(T x, int k) {
        if (k >= _n-1) {
            return k - (_n - 1);  // 葉
        } else if (_data[k] < x) {
            return _n;  // 該当なし
        } else if (x <= _data[k * 2 + 1]) {
            return _lower_bound(x, k * 2 + 1);
        } else {
            return _lower_bound(x - _data[k * 2 + 1] , k * 2 + 2);
        }
    }
};
// }}}

ll f(ll x, ll y){
  return x+y;
}

signed main() {
  ll N, K;
  cin >> N >> K;
  SegTree<ll> st(N, 0, f);
  rep(i,N) {
    ll x;
    cin >> x;
    st.update(i, x);
  }
  vector<ll> v;
  for (ll i=0; i<N; i++) {
    for (ll j=i; j<N; j++) {
      v.push_back(st.query(i, j+1));
    }
  }
  sort(begin(v), end(v));
  //cout << "v: ";
  //for(auto x: v) {
  //  cout << x << " ";
  //}
  //cout << endl;

  vector<ll> can;
  rep(i, v.size())
    can.push_back(i);

  for (ll bit=((ll)1)<<50; bit>0; bit = bit >> 1) {
    vector<ll> t;
    for(auto ix : can) {
      if ((v[ix] & bit) != 0) {
        t.push_back(ix);
      }
    }
    //printf("bit: %08X can: ", bit);
    //for(auto ix : can) {
    //  cout << v[ix] << " ";
    //}
    //printf("t: ");
    //for(auto ix : t) {
    //  cout << v[ix] << " ";
    //}
    //cout << endl;
    if (t.size() == K) {
      can = t;
      break;
    } else if (t.size() > K) {
      can = t;
    } else {
      ; // none
    }
  }

  ll ans = v[can[0]];
  rep(i,K){
    auto ix = can[i];
    ans &= v[ix];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11888
#include <iostream>
#include <vector>
using namespace std;
using Mat = vector<vector<bool>>;
int w, h;
const int dxy[10] = {0,1,1,1,0,-1,-1,-1,0,1};
void search(const Mat &map, Mat &searched, int x, int y, int dir) {
    if (x < 0 || w <= x || y < 0 || h <= y) {
        return;
    } else if (!map[x][y] || searched[x][y]) {
        return;
    }
    
    searched[x][y] = true;
    
    for (int i = 0; i < 8; ++i) {
        search(map, searched, x + dxy[i], y + dxy[i+2], i);
    }
}
int main(void){
    while (cin >> w >> h && w && h) {
        Mat map(w, vector<bool>(h, false));
        for (int y = 0; y < h; ++y) {
            for (int x = 0; x < w; ++x) {
                int c;
                cin >> c;
                map[x][y] = c;
            }
        }
        Mat searched(w, vector<bool>(h, false));
        int count = 0;
        for (int y = 0; y < h; ++y) {
            for (int x = 0; x < w; ++x) {
                if (searched[x][y] || !map[x][y]) continue;
                search(map, searched, x, y, -1);
                ++count;
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3264
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

#define fst first
#define snd second

typedef long long llint;
typedef pair<int, int> pii;

const int B = 27397, MOD = 1e9 + 7;
const int B1 = 33941, MOD1 = 1e9 + 9;

int n, sol;
int l[201];

int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < 2*n; ++i)
    scanf("%d", &l[i]);

  sort(l, l + 2*n);
  for (int i = 0; i < 2*n; i += 2)
    sol += l[i];

  printf("%d\n", sol);
  return 0;
}

Measured memory_bytes: 256
/* Filename: ARC083C.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			int E = input.nextInt();
			int F = input.nextInt();
			int maxA = F / (A * 100);
			int maxB = F / (B * 100);
			int maxC = F / C;
			int maxD = F / D;
			
			int sugarWater = 100;
			int sugar = 0;
			double maxDensity = 0;
			for(int a = 0; a <= maxA; ++a){
				for(int b = 0; b <= maxB; ++b){
					for(int c = 0; c <= maxC; ++c){
						for(int d = 0; d <= maxD; ++d){
							int currentWater = (a * A + b * B) * 100;
							int currentSugar = c * C + d * D;
							
							if( currentWater + currentSugar <= F){
								if(currentWater / 100 * E >= currentSugar){
									double currentDensity = currentSugar == 0 ? 0 : currentSugar / (double) (currentSugar + currentWater);
									
									if(currentDensity >= maxDensity){
										sugar = currentSugar;
										sugarWater = sugar + currentWater;
										maxDensity = currentDensity;
									}
								}
							}
						}
					}
				}
			}
			
			System.out.println(sugarWater + " " + sugar);
		}
	}

}


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

int main(){
  char C;
  cin>>C;
  printf("%c\n", C+1);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
vector<P> G[800];
int p[800], d[800];
int cost1[800], cost2[800];
bool leave[800];
void pre(int idx, int par) {
	int cnt = 0;
	for (int i = 0; i < G[idx].size(); i++) {
		if (G[idx][i].first == par) continue;
		pre(G[idx][i].first, idx);
		cnt++;
	}
	leave[idx] = (cnt == 0);
}
int solve1(int idx,int par) {
	int sum = 0;
	if (leave[idx]) return cost1[idx] = 0;
	for (int i = 0; i < G[idx].size(); i++) {
		if (G[idx][i].first == par) continue;
		if (leave[G[idx][i].first]) sum += G[idx][i].second;
		else sum += G[idx][i].second * 3;
		sum += solve1(G[idx][i].first, idx);
	}
	return cost1[idx] = sum;
}
int solve2(int idx,int par) {
	int tmp = cost1[idx];
	int ans = tmp;
	if (leave[idx]) return cost2[idx] = 0;
	for (int i = 0; i < G[idx].size(); i++) {
		if (G[idx][i].first == par || leave[G[idx][i].first]) continue;
		int sum = tmp;
		sum -= G[idx][i].second;
		sum -= cost1[G[idx][i].first];
		sum += solve2(G[idx][i].first, idx);
		ans = min(ans, sum);
	}
	return cost2[idx] = ans;
}
int main() {
	int n;
	while (scanf("%d", &n), n) {
		for (int i = 1; i < n; i++) {
			scanf("%d", &p[i]);
			p[i]--;
		}
		for (int i = 1; i < n; i++) {
			scanf("%d", &d[i]);
		}
		for (int i = 0; i < n; i++) {
			G[i].clear();
		}
		for (int i = 1; i < n; i++) {
			G[p[i]].push_back(P(i, d[i]));
			G[i].push_back(P(p[i], d[i]));
		}
		int ans = 1 << 30;
		for (int i = 0; i < n; i++) {
			pre(i, -1);
			solve1(i, -1);
			ans = min(ans, solve2(i, -1));
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const ll MOD = ll(1e9) + 7;

vector<int> sieve(int n) {
  vector<int> res(n);
  iota(res.begin(), res.end(), 0);
  for (int i = 2; i * i < n; ++i) {
    if (res[i] < i) continue;
    for (int j = i * i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}

set<int> factor(int n, const vector<int>& min_factor) {
  set<int> res;
  while (n > 1) {
    res.insert(min_factor[n]);
    n /= min_factor[n];
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<int> min_factor = sieve(1000005);
  vector<int> kaisuu(1000005);
  int a;
  rep(i, n) {
    cin >> a;
    for (int el : factor(a, min_factor)) {
      kaisuu[el]++;
    }
  }
  bool pair = true;
  bool setwise = true;
  rep(i, 1000005) {
    if (kaisuu[i] > 1) pair = false;
    if (kaisuu[i] == n) setwise = false;
  }
  string ans = "pairwise coprime";
  if (!pair) ans = "setwise coprime";
  if (!setwise) ans = "not coprime";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11152
-- Question A

import Control.Applicative
import Control.Monad

main = do
  [n ,k] <- (map read . words) <$> getLine ::IO[Integer]
  xs <- (map read . words) <$> getLine ::IO[Integer]
  putStrLn (try xs k) 
  
  
try xs k
 | ( maximum xs ) < k = "IMPOSSIBLE"
 | (k `mod` (foldl1 (getGcd) xs) )==0 = "POSSIBLE"
 | otherwise = "IMPOSSIBLE"

getGcd :: Integer -> Integer -> Integer
getGcd a 0 = a
getGcd a b
    | a `mod` b == 0 = b
    | otherwise = getGcd b $ a `mod` b

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

using namespace std;


#define N 100000  
//[][0] がend [][1]がcount
int table[N];

int main() {
    int n, q;
    string str;
    int begin, end;
 

    cin >> n >> q;
    cin >> str;
    
    //make a table
    for (int i = 0; i < n-1; i++) {
        table[i+1] = table[i] + ((str[i] == 'A' && str[i+1] == 'C') ? 1 : 0);
    }
    
    for (int i = 0; i < q; i++) {
        cin >> begin >> end;
        cout << table[end-1] - table[begin-1] << endl;  
    }
    return 0;
}

Measured memory_bytes: 1408
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
def stoq(s):
    q = deque()
    for i in range(len(s)):
        q.append(s[i])
    return q
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

S = list(map(stoq,[input() for _ in range(3)]))
k = 0
while True:
    if len(S[k])==0:
        break
    c = S[k].popleft()
    k = ston(c)
print(ntos(k,'A'))

Measured memory_bytes: 67600
#include <stdio.h>
int main()
{
	int a[105],i=0,n,x,y,k,sum=1;
	scanf("%d",&n);
	while(i<n){
		scanf("%d",&a[i]);
		i++;
	}
	for(x=0;x<i-1;x++){
		for(y=x+1;y<i;y++){
			if(a[x]>a[y]){
				k=a[x];
				a[x]=a[y];
				a[y]=k;
			}
		}
	}
	for(x=0;x<i-1;x++){
		if(a[x]!=a[x+1]){
			sum++;
		}
	}
	printf("%d",sum);
} 

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main(){
 
  	int S,W;
  	if(scanf("%d%d",&S,&W) < 2) {
      fprintf(stderr, "error: ill-formed fraction.\n");
      exit(1);
	}
  
	if(S > W){
    	printf("safe");
    } else {
    	printf("unsafe");
    }
  	return 0;
}

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

using namespace std;

int main(){
    int A, B, C, D;
    int MAX_1, MAX_2;
    cin >> A >> B >> C >> D;
    MAX_1 = min(A, B);
    MAX_2 = min(C, D);

    cout << MAX_1 + MAX_2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin >> N;

  int dmin = 100;
  for (int i=0;i<N;i++) {
    int x,d=0;
    cin >> x;
    while (x % 2 == 0) {
      x /= 2;
      d++;
    }
    dmin = min(dmin,d);
  }

  cout << dmin << endl;
}

Measured memory_bytes: 256
import itertools
N,M,X = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
B = list(itertools.product([0,1], repeat=N))#bit探索
sums = {}
anss = []
for i in range(N):
    for b in B:#直積を使う
        #print(b)#BITで増えていく仕組み
        #print(sums)
        #print(anss)
        ans = 0
        Point = [0]*M
        #print(Point)
        count = 0
        for z in b:
            #print(z)#bの中の内容を１つづつやっているのと一緒
            if z == 1:
                for k in range(M):
                    Point[k] += A[count][k+1]
                ans += A[count][0]
                #print(Point)
                if M == len([Point[n] for n in range(M) if Point[n] >= X]):
                    #何一つもXより大きいかという条件を外れてはいけない
                    anss.append(ans)
            count += 1
if len(anss) != 0:
    print(min(anss))
else:
    print(-1)


Measured memory_bytes: 19972