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

typedef long long ll;
const int N = 2e5;


pair<ll,ll> dat[N + 5];

ll ST[4 * N + 5];
ll lazy[4 * N + 5];

void build(int idx, int l, int r) {
	if(l == r) {
		ST[idx] = dat[l].S;
		return ;
	}
	int mid = (l + r) / 2;
	build(2 * idx, l, mid), build(2 * idx + 1, mid + 1, r);
	ST[idx] = min(ST[2 * idx], ST[2 * idx + 1]);
}

void pushdown(int idx) {
	ST[2 * idx] += lazy[idx];
	ST[2 * idx + 1] += lazy[idx];
	lazy[2 * idx] += lazy[idx];
	lazy[2 * idx + 1] += lazy[idx];
	lazy[idx] = 0;
}

ll query(int idx, int l, int r, int tar) {
	if(l == r) return ST[idx];
	pushdown(idx);
	int mid = (l + r) / 2;
	if(tar <= mid) return query(2 * idx, l, mid , tar);
	else return query(2 * idx + 1, mid + 1, r, tar);
}

void update(int idx, int l, int r, int le, int ri, ll v) {
	if(r < le || ri < l) return ;
	if(le <= l && r <= ri) {
		ST[idx] -= v;
		lazy[idx] -= v;
		return ;
	}
	int mid = (l + r) / 2;
	update(2 * idx, l, mid, le, ri, v);
	update(2 * idx + 1, mid + 1, r, le, ri, v);
	ST[idx] = min(ST[2 * idx], ST[2 * idx + 1]);
}

int main() {
	int n, d, a;
	cin>>n>>d>>a;
	for(int i = 1;i <= n;i++) {
		cin>>dat[i].F>>dat[i].S;
	}
	sort(dat + 1, dat + 1 + n);
	build(1, 1, n);
	ll total = 0;
	for(int i = 1;i <= n;i++) {
		ll bakuretsu = query(1, 1, n, i);
		if(bakuretsu >= 0) {
			ll reduce = (bakuretsu + a - 1) / a;
			total += reduce;
			int l = i;
			int r = n;
			int rhs = n;
			while(l <= r) {
				int mid = (l + r) / 2;
				if(dat[mid].F - d <= dat[i].F + d) {
					rhs = mid;
					l = mid + 1;
				} else r = mid - 1;
			}
			update(1, 1, n, i, rhs, reduce * a);
		}
	}
	cout<<total<<endl;
}

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

typedef long long LL;
typedef unsigned long long ULL;

const int PI = 3.141592653589793;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 200007;

int main(){

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

        int x; cin >> x;
        if (x >= 30) {
            cout << "Yes\n";
        }
        else cout << "No\n";
        return 0;
}



Measured memory_bytes: 3636
#include<iostream>
using namespace std;
string s,t;
main()
{
cin>>s>>t;
  for(int i=0;i<s.size();i++)
  {
    bool f=1;
    for(int j=0;j<s.size();j++)f&=s[(i+j)%s.size()]==t[j];
    if(f)
    {
cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define MAX 1001000
#define MOD 1000000007
#define endl "\n"
lli arr[MAX];
lli N;
lli M;
lli Q;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli t;
    t = 1;
    while(t--){
            lli N,M;
            cin>>N>>M;
            lli a = N/2;
            lli b = N/2+1;
            if(N%2 == 0){
                vector <bool> visited(N+5, 0);
                lli aeven = 1;
                lli beven = N/2;
                lli aodd = N;
                lli bodd = N/2 + 2;
                while(beven > aeven & M > 0){
                    cout<<aeven<<" "<<beven<<endl;
                    aeven++;
                    beven--;
                    M--;
                    }
                while(aodd > bodd & M > 0){
                    cout<<aodd<<" "<<bodd<<endl;
                    aodd--;
                    bodd++;
                    M--;
                }
            }
            else{
                for(lli i = 0; i<M; i++){
                    cout<<a<<" "<<b<<endl;
                    a--;
                    b++;
                }
            }
        }
    }

Measured memory_bytes: 3632
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

struct edge{ll from, to, weight;};

int main(){
  ll n;
  cin >> n;
  str w[n];
  std::map<str, ll> mp;
  REP(i,n){
    cin >> w[i];
    if(i!=0&&(w[i-1].back()!=w[i].front()||mp[w[i]]>0)){
      cout << "No" << endl;
      return 0;
    }
    mp[w[i]]++;
  }
  cout << "Yes" << endl;
  return 0;
}


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

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

    for(double i=1; i<1e6; i++) {
        if(floor(i*0.08) == a && floor(i*0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int D = sc.nextInt();
            int T = sc.nextInt();
            int S = sc.nextInt();
            if ((double)D / S <= T) {
            	System.out.println("Yes");
            } else {
            	System.out.println("No");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

signed main(void){
    string S;
    cin >> S;
    if(S=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }
    
    return 0;
}




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

#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int h, w;
  cin >> h >> w;
  vt<string> a(h);
  rep(i, 0, h) cin >> a[i];

  queue<pair<pi, int>> que;
  rep(i, 0, h) {
    rep(j, 0, w) {
      if(a[i][j] == '#') que.push({{i, j}, 0});
    }
  }

  int ans;
  while(!que.empty()) {
    auto p = que.front();
    que.pop();
    ans = p.second;
    rep(i, 0, 4) {
      int ny = p.first.first + dy[i], nx = p.first.second + dx[i];
      if(0 <= ny && ny < h && 0 <= nx && nx < w && a[ny][nx] == '.') {
        que.push({{ny, nx}, p.second + 1});
        a[ny][nx] = '#';
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13456
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int N =sc.nextInt();
    long T =sc.nextLong();
    long t[] =new long[N];
    t[0]=sc.nextLong();
    long S =t[0];
    long M =t[0]+T;
    long ans =0;
    if(N==1){ans =ans+T;}
    for(int i=1;i<N;i++){
      t[i]=sc.nextLong();
      if(t[i]<M){
        M=t[i]+T;}
      else{ans =ans+M-S;
           M=t[i]+T;
           S=t[i];}
      if(i==N-1){ans =ans +M-S;}}
    System.out.println(ans);
  }
}

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

using namespace std;

void GoPlus(int, int, int&);
void GoMinus(int, int&);

int main(){
  int n, m, a, x, y;
  char way;
  string str;

  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    x = 1;
    y = 1;
    way = 'N';
    while(1){
      cin >> str;
      if(str == "STOP") break;

      if(str == "FORWARD"){
	cin >> a;
	if(way == 'N') GoPlus(m, a, y);
	else if(way == 'S') GoMinus(a, y);
	else if(way == 'E') GoPlus(n, a, x);
	else if(way == 'W') GoMinus(a, x);
      }else if(str == "BACKWARD"){
	cin >> a;
	if(way == 'N') GoMinus(a, y);
	else if(way == 'S') GoPlus(m, a, y);
	else if(way == 'E') GoMinus(a, x);
	else if(way == 'W') GoPlus(n, a, x);
      }else if(str == "RIGHT"){
	if(way == 'N') way = 'E';
	else if(way == 'S') way = 'W';
	else if(way == 'E') way = 'S';
	else if(way == 'W') way = 'N';
      }else if(str == "LEFT"){
	if(way == 'N') way = 'W';
	else if(way == 'S') way = 'E';
	else if(way == 'E') way = 'N';
	else if(way == 'W') way = 'S';
      }
    }
    cout << x << " " << y << endl;
  }
  return 0;
}

void GoPlus(int n, int a, int& x){
  x += a;
  if(x > n) x = n;
}

void GoMinus(int a, int& x){
  x -= a;
  if(x < 1) x = 1;
}

Measured memory_bytes: 1204
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = (int)1e5 + 10;
ll l[maxN], r[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> l[i] >> r[i];
    }
    if (n == 1) {
        cout << 0;
        return 0;
    }
    priority_queue < ll > S1;
    priority_queue < ll, vector < ll >, greater<>>S2;
    S1.push(r[1]);
    S2.push(r[1]);
    ll shift1 = 0;
    ll shift2 = 0;
    ll ans = 0;
    for (int i = 2; i <= n; i++) {
        ll len1 = r[i] - l[i];
        ll len2 = r[i - 1] - l[i - 1];
        shift1 -= len2;
        shift2 += len1;
        ll stL = S1.top() + shift1;
        ll stR = S2.top() + shift2;
        if (r[i] >= stR) {
            S2.pop();
            S2.push(r[i] - shift2);
            S2.push(r[i] - shift2);
            S1.push(stR - shift1);
            ans += r[i] - stR;
        }
        else if (r[i] <= stL) {
            S1.pop();
            S1.push(r[i] - shift1);
            S1.push(r[i] - shift1);
            S2.push(stL - shift2);
            ans += stL - r[i];
        }
        else {
            S1.push(r[i] - shift1);
            S2.push(r[i] - shift2);
        }
        // should take min(x - len1,
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;

const int MOD = 100000;

int n, m;
int s[100010], a[100010];
LL ans = 0;
int main()
{
  scanf("%d%d", &n, &m);
  for(int i = 2; i <= n; i++){
    scanf("%d", &s[i]);
    s[i] += s[i - 1];
  }
  for(int i = 1; i <= m; i++)
    scanf("%d", &a[i]);
  
  int now = 1;
  for(int i = 1; i <= m; i++){
    ans = (ans + abs(s[now + a[i]] - s[now])) % MOD;
    now += a[i];
  }
  
  printf("%lld\n", ans);
  return 0;
}

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

struct UF {
  vector<int> p;
  int n;

  UF(int siz) {
    n = siz;
    p.resize(n, 0);
    for (int i = 0; i < n; i++) p[i] = i;
  }

  int parent(int x) {
    if (p[x] != x) p[x] = parent(p[x]);
    return p[x];
  }

  bool same(int x, int y) { return parent(x) == parent(y); }

  void unite(int x, int y) {
    x = parent(x), y = parent(y);
    p[x] = y;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i], p[i]--;
  vector<int> x(m), y(m);
  UF uf(n);
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
    uf.unite(x[i], y[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) ans += uf.parent(p[i]) == uf.parent(i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4752
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i, a, b) for (size_t i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

const int MAX_V = 2000001;
int w_table[MAX_V];
int e_table[MAX_V];

void calc_table(const int& n, const string& s)
{
    w_table[0] = 0;
    e_table[0] = 0;
    for (size_t i = 1; i <= n; ++i)
        if (s[i - 1] == 'W') {
            w_table[i] = w_table[i - 1] + 1;
            e_table[i] = e_table[i - 1];
        }
        else {
            e_table[i] = e_table[i - 1] + 1;
            w_table[i] = w_table[i - 1];
        }
}

int solve(const int n, string s)
{
    int count = 1 << 30;
    FOR(i, 1, n + 1) {
        count = min(count, w_table[i - 1] + e_table[n] - e_table[i]);
    }
    return count;
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    calc_table(n, s);
    // REP(i, n + 1)
    //     cout << w_table[i] << " ";
    // cout << endl;
    // REP(i, n + 1)
    //     cout << e_table[i] << " ";
    // cout << endl;
    cout << solve(n, s) << endl;
}



Measured memory_bytes: 5892
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  int A,B,C,X,Y,ans1,ans2,ans3,ans4;
  cin>>A>>B>>C>>X>>Y;
  ans1=A*X+B*Y;
  ans2=C*Y*2+A*(X-Y);
  if(X-Y<0) ans2=ans1;
  ans3=C*X*2+B*(Y-X);
  if(Y-X<0) ans3=ans1;
  ans4=max(X,Y)*C*2;
  
  cout<<min(min(ans1,ans4),min(ans2,ans3))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define alluniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

signed main()
{
  vector<int> x, y, d;
  
  int N, K;
  int X1[55], Y1[55], D1[55], X2[55], Y2[55], D2[55];
  int ans = 0;
  
  cin >> N >> K;
  Rep(i, N) {
    cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
    x.pb(X1[i]); x.pb(X2[i]);
    y.pb(Y1[i]); y.pb(Y2[i]);
    d.pb(D1[i]); d.pb(D2[i]);
  }

  sort(all(x)); sort(all(y)); sort(all(d));
  alluniq(x); alluniq(y); alluniq(d);

  Rep(i, x.size() - 1) {
    Rep(j, y.size() - 1) {
      Rep(k, d.size() - 1) {
	int cnt = 0;
	Rep(l, N) {
	  if(X1[l] <= x[i] && x[i + 1] <= X2[l] && Y1[l] <= y[j] && y[j + 1] <= Y2[l] && D1[l] <= d[k] && d[k + 1] <= D2[l]) cnt++;
	}
	if(cnt >= K) ans += (x[i + 1] - x[i]) * (y[j + 1] - y[j]) * (d[k + 1] - d[k]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define mem(a,b) memset((a),(b),sizeof(a))
#define MP make_pair
#define pb push_back
#define fi first
#define se second
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
using namespace std;
#define _GLIBCXX_PERMIT_BACKWARD_HASH
#include <ext/hash_map>
using namespace __gnu_cxx;
struct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};
typedef long long ll;
typedef unsigned long long ull;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDD pair<double,double>
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double eps=1e-6;
const int MAX=1e6+10;
const ll mod=1e9+7;
int main()
{
	ll a,b,c,k,aa,bb,cc,pre1,pre2,pre3;
	while(cin>>a>>b>>c>>k)
	{
		k=k%2;
		while(k>0)
		{
/*			if(pre1==a-b&&pre2==a-c&&pre3==b-c)
			{
				break;
			}*/
			pre1=a-b;
			pre2=a-c;
			pre3=b-c;
			k=k-1;
			aa=b+c;
			bb=a+c;
			cc=a+b;
			if(abs(aa-bb)>1e18)
			{
				puts("Unfair");
				goto end;
			}
			a=aa;
			b=bb;
			c=cc;
	//		cout<<a<<" "<<b<<" "<<c<<" "<<a-b<<" "<<b-c<<endl;
		}
		if(abs(a-b)>1e18) puts("Unfair");
		else cout<<a-b<<"\n";
		end:;
	} 
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
using namespace __gnu_pbds;
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll n;
vector<ll> v;

ll cnt(ll x) {
  ll anw = 0;
  while(x % 2 == 0) {
    anw++;
    x /= 2;
  }
  return anw;
}

int main() {
  ios::sync_with_stdio(0);
  cout.precision(10);

  cin >> n;
  v.resize(n);

  ll anw = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    anw += cnt(v[i]);
  }

  cout << anw << endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

int main ()
{
	for (int i=1; ; ++i) {
		int x;
		cin >> x;
		if (0 == x) break;

		cout << "Case " << i << ": " << x << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int x[N], y[N];
int n, m;
char s[N][11];
int main(){
	int t;
	// while(){
	scanf("%d",&n);
	vector<pair<int,int>>v1,v2, v3, v4, v5, v6;
	for(int i=0; i<n; ++i){
		scanf("%d%d%s",x+i, y+i, s[i]);
		if(s[i][0]=='U'){
			v1.push_back(mk(x[i], i));
			v5.push_back(mk(y[i], i));
		}
		else if(s[i][0]=='D'){
			v2.push_back(mk(x[i], i));
			v6.push_back(mk(y[i], i));
		}
		else if(s[i][0]=='R'){
			v3.push_back(mk(x[i], i));
		}
		else{
			v4.push_back(mk(x[i], i));
		}
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	sort(v3.begin(), v3.end());
	sort(v4.begin(), v4.end());

	sort(v5.begin(), v5.end());
	sort(v6.begin(), v6.end());

	int ans=1e9;
	int j=0, j1=0, j2=0;
	map<int, int> mp, mp1, mp2;
	for(int i=0; i<v4.size(); ++i){
		for(j;j<v1.size(); ++j){
			if(v1[j].fs>v4[i].fs)break;
			auto tmp=v1[j].sc;
			mp[x[tmp]-y[tmp]]=x[tmp];
		}
		auto tmp=v4[i].sc;
		if(mp.count(x[tmp]-y[tmp])){
			ans=min(ans, (x[tmp]-mp[x[tmp]-y[tmp]])*10);
		}

		for(j1;j1<v3.size(); ++j1){
			if(v3[j1].fs>v4[i].fs)break;
			auto tmp=v3[j1].sc;
			mp1[y[tmp]]=x[tmp];
		}
		 tmp=v4[i].sc;
		if(mp1.count(y[tmp])){
			ans=min(ans, (x[tmp]-mp1[y[tmp]])*5);
		}

		for(j2; j2<v2.size(); ++j2){
			if(v2[j2].fs>v4[i].fs)break;
			auto tmp=v2[j2].sc;
			mp2[x[tmp]+y[tmp]]=x[tmp];
		}
		 tmp=v4[i].sc;
		if(mp2.count(x[tmp]+y[tmp])){
			ans=min(ans, (x[tmp]-mp2[x[tmp]+y[tmp]])*10);
		}
	}
	mp.clear();
	mp1.clear();
	j=(int)v1.size()-1;
	j1=(int)v2.size()-1;
	for(int i=(int)(v3.size())-1; i>=0; --i){
		for(j; j>=0; --j){
			if(v1[j].fs<v3[i].fs)break;
			auto tmp=v1[j].sc;
			mp[x[tmp]+y[tmp]]=x[tmp];
		}
		auto tmp=v3[i].sc;
		if(mp.count(x[tmp]+y[tmp])){
			ans=min(ans, (mp[x[tmp]+y[tmp]]-x[tmp])*10);
		}

		for(j1; j1>=0; --j1){
			if(v2[j1].fs<v3[i].fs)break;
			auto tmp=v2[j1].sc;
			mp1[x[tmp]-y[tmp]]=x[tmp];
		}
		 tmp=v3[i].sc;
		if(mp1.count(x[tmp]-y[tmp])){
			ans=min(ans, (mp1[x[tmp]-y[tmp]]-x[tmp])*10);
		}
	}

	j=0;
	mp.clear();
	for(int i=0; i<v6.size(); ++i){
		for(j; j<v5.size(); ++j){
			if(v5[j].fs>v6[i].fs)break;
			auto tmp=v5[j].sc;
			mp[x[tmp]]=y[tmp];
		}
		auto tmp=v6[i].sc;
		if(mp.count(x[tmp])){
			ans=min(ans, (y[tmp]-mp[x[tmp]])*5);
		}
	}
	if(ans==1e9)
		printf("SAFE\n");
	else
		cout<<ans<<endl;
	// }
}

Measured memory_bytes: 19284
while True:
  n, r = map(int, input().split())
  if n==0 and r==0:
    break

  yama = [i for i in range(n, 0, -1)]
  for _ in range(r):
    p, c = map(int, input().split())
    up, bottom = [], []
    up.extend(yama[p-1:p+c-1])
    up.extend(yama[:p-1])
    bottom.extend(yama[p+c-1:])
    up.extend(bottom)
    yama = up[:]
  print(yama[0])


Measured memory_bytes: 5624
import math

n=int(input())
s=[list(map(int,input().split())) for i in range(n)]


dist=0
a=math.factorial(n)
for i in range(n):
  for j in range(i+1,n):
    dist+=math.sqrt((s[i][0]-s[j][0])**2+(s[i][1]-s[j][1])**2)
print(dist*2/n)

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

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
typedef long long ll;

/* 2017/01/20 問題 -----  ABC048 C /Link  */
/* -----解説等-----
問題: N 個の箱が横一列に並んでいます。 最初、左から i 番目の箱には ai 個のキャンディが入っています。

すぬけ君は次の操作を好きな回数だけ行うことができます。

キャンディが 1 個以上入っている箱をひとつ選び、その箱のキャンディを 1 個食べる。
すぬけ君の目標は次の通りです。

どの隣り合う 2 つの箱を見ても、それらの箱に入っているキャンディの個数の総和が x 以下である。
目標を達成するために必要な操作回数の最小値を求めてください。


取り出す要件として端から順にｘを超えてしまうものを削減していけばよい。
新しく見つけた要素に対して削減を常に行うようにすれば次回に削減しなくてもよい可能性が存在するので
この探し方が最小解を求める手段である。Ｏ(N)

*/

int N, x;
int a[100000];
ll ans = 0;

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

    cin >> N >> x;
    FOR(i, 0, N) {
        cin >> a[i];
    }
    FOR(i, 0, N - 1) {
        ll sum = a[i] + a[i + 1];
        if (sum <= x)continue;
        
        ll sub = sum - x;
        if (sub <= a[i + 1]) a[i + 1] -= sub;
        else {
            ll subsub = sub;
            subsub -= a[i + 1];
            a[i + 1] = 0;
            a[i] -= subsub;
        }
        ans += sub;
    }


    cout << ans << endl;

    return 0;
}

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




int ASCttenannoryaku(const void *a,const void *b) {
	return *(int *)a - *(int *)b;
}
int main(void)
{
	long a, b, n;
	scanf("%ld%ld%ld",&n,&a,&b);
	long ans = (n / (a + b))*a;
	long keep = n % (a + b);
	if (keep <= a)
		ans += keep;
	else if (keep > a)
		ans += a; 
	printf("%ld", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int oddcnt = 0, evencnt = 0;
    REP(i,N){
        int a; cin >> a;
        if(a%2 == 1) oddcnt++;
        else evencnt++;
    }
    if(oddcnt % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;

}

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

#define sz(a) ((int)a.size())
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define forse(i,s,e) for(int i=(int)s;i<(int)e;i++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using dbl=double;
using ll=long long;
using pii=pair<int, int>;
using pll=pair<ll, ll>;

dbl PI=3.141592653589793;


void solve(){
	int n;
	cin >> n;
	map<string,int> cnt;
	forn(i,n){
		string in;cin >> in;
		cnt[in]++;
	}
	cout << "AC x " << cnt["AC"] << '\n';
	cout << "WA x " << cnt["WA"] << '\n';
	cout << "TLE x " << cnt["TLE"] << '\n';
	cout << "RE x " << cnt["RE"] << '\n';
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	for(int c=1;c<=T;c++){
		solve();
	}
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int getint() {
	char C;
	while (!isdigit(C = getchar()));
	int A = C - '0';
	while (isdigit(C = getchar())) A = A * 10 + C - '0';
	return A;
}

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


	int N = getint();
	int odd = N & 1;
	ll mod = 1e9 + 7;
	ll kotae = 1;
	int A[100000] = {};
	rep(i, N) {
		int a = getint();
		A[a]++;
	}
	if (odd) {
		if (A[0] != 1) {
			co(0);
			return 0;
		}
		for (int i = 2; i < N; i += 2) {
			if (A[i] != 2) {
				co(0);
				return 0;
			}
			kotae = kotae * 2 % mod;
		}
	}
	else {
		for (int i = 1; i < N; i += 2) {
			if (A[i] != 2) {
				co(0);
				return 0;
			}
			kotae = kotae * 2 % mod;
		}
	}
	co(kotae);

	Would you please return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    bool flag = true;
    int tmp;

    rep(i, n) {
        cin >> tmp;
        if (tmp % 2 == 0) {
            if (tmp % 3 != 0 && tmp % 5 != 0) flag = false;
        }
    }

    cout << (flag ? "APPROVED" : "DENIED") << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x string
	fmt.Scan(&x)

	ans := 0
	sta := 0
	for _, xx := range x {
		if xx == 'S' {
			sta++
		} else {
			if sta > 0 {
				sta--
			} else {
				ans++
			}
		}
	}

	fmt.Println(ans + sta)
}


Measured memory_bytes: 1920
N,M = map(int,input().split())
A = [1 for _ in range(N+1)]
B = [0 for _ in range(N+1)]
B[1] = 1
for _ in range(M):
    a,b = map(int,input().split())
    A[b] += 1
    if B[a]==1 and B[b]==0:
        B[b] = 1
    A[a] -= 1
    if B[a]==1 and A[a]==0:
        B[a] = 0
print(sum(B))

Measured memory_bytes: 4656
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_number(A),
    get_number(B),
    get_number(C),
    X is max(max(A, B), C),
    Y is A + B + C - X,
    X = Y -> writeln("Yes") ; writeln("No").


Measured memory_bytes: 7968
console.log((args=>{
  const [sx,sy,tx,ty] = args.trim().split` `.map(v=>0|v);
  const p1 = 'U'.repeat(ty-sy) + 'R'.repeat(tx-sx);
  const p2 = 'D'.repeat(ty-sy) + 'L'.repeat(tx-sx);
  const p3 = 'LU' + p1 + 'RD';
  const p4 = 'RD' + p2 + 'LU';
  return p1+p2+p3+p4;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 29476
#include <iostream>
#include <algorithm>
using namespace std;
void printArray(int a[],int n){
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i<n-1){
            cout << " ";
        }
    }
    cout << endl;
}
int bubbleSort(int a[],int n){
    int flag = 1;
    int switchNum = 0;
    while(flag){
        flag = 0;
        for(int i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                int temp = a[i];
                a[i] = a[i-1];
                a[i-1] = temp;
                switchNum = switchNum + 1;
                flag = 1;
            }
        }
    }
    return switchNum;
}
int main(){
    int n;
    cin >> n;
    int a[n];
    int num;
    if(n>=1 && n<=100){
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        num = bubbleSort(a,n);
        printArray(a,n);
        cout << num << endl;
    }else{
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3092
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ls (id * 2)
#define rs (id * 2 + 1)

int n, q, s, t, x;
long long S[400020], lazy[400020];
bool com;
bitset<400020> tag;

void pd(int id, int l, int m, int r) {
    if (!tag[id]) return;
    S[ls] += lazy[id] * (m - l + 1);
    S[rs] += lazy[id] * (r - m);
    lazy[ls] += lazy[id];
    lazy[rs] += lazy[id];
    lazy[id] = 0;
    tag[ls] = tag[rs] = 1;
    tag[id] = 0;
}

void update(int id, int l, int r, int ql, int qr, int v) {
    if (ql > r || qr < l) return;
    if (ql <= l && r <= qr) {
        S[id] += v * (r - l + 1);
        lazy[id] += v;
        tag[id] = 1;
        return;
    }
    int m = (l + r) /2;
    pd(id, l, m, r);
    update(ls, l, m, ql, qr, v);
    update(rs, m + 1, r, ql, qr, v);
    S[id] = S[ls] + S[rs];
}

long long query(int id, int l, int r, int ql, int qr) {
	if (ql > r || qr < l) return 0;
	if (ql <= l && r <= qr) return S[id];
	int m = l + r >> 1;
	pd(id, l, m, r);
	return (query(ls, l, m, ql, qr) + query(rs, m + 1, r, ql, qr));
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> q;
    while (q--) {
        cin >> com >> s >> t;
        if (!com) {
            cin >> x;
            update(1, 1, n, s, t, x);
        } 
        else cout << query(1, 1, n, s, t) << endl;
    }
}


Measured memory_bytes: 7328
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 2*1e5 + 10;
const long double PI = acos(-1);
vector<ll> path, v(maxn);

pii cicle(ll x0){
    ll t = v[x0], h = v[v[x0]];
    while (t!=h) t = v[t], h = v[v[h]];

    ll mu = 0;
    h = x0;

    while (t != h) t = v[t], h = v[h], mu++;

    ll lambda = 1;
    h = v[t];

    while (t != h) h = v[h], lambda++;

    return pii(mu, lambda);

}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, k, id = 0;
    pii tmp;
    cin >> n >> k;

    bitset<maxn> vis(0);

    for (int i=0; i<n; i++) cin >> v[i], v[i]--;
    tmp = cicle(0);

    while (!vis[id])
    {
        vis[id] = 1;
        path.push_back(id);
        id = v[id];
    } 

    if (k < path.size()){
        cout << path[k]+1 << endl;
    }
    else {
        k -= tmp.ff;
        k %= tmp.ss;
        cout << path[tmp.ff + k] +1 << endl;
    }
    return 0;
}

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

int main() {
	int n,m,i,j,k,ans,cur;
	string s,t;
	cin >> s >> t;
	n=s.size(); m=t.size();
	ans=m;
	for(i=0; i+m-1<n; i++){
		cur=m;
		for(j=0; j<m; j++){
			if(s[i+j]==t[j]){
				cur--;
			}
			
		}
		ans=min(ans,cur);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
R, G, B, N = [int(i) for i in input().split()]

cnt = 0
for r in range(0, N // R + 1):
  for g in range(0, (N - r * R) // G + 1):
    rest = N - (r * R + g * G)
    if rest >= 0 and rest % B == 0:
      cnt += 1

print(cnt)

Measured memory_bytes: 9108
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int a,b;
  cin>>a>>b;
  (a<1 || a>9) || (b<1 || b>9) ? cout<<-1<<endl : cout<<a*b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if (a <= 0 && 0 <= b) printf("Zero\n");
	else if (a > 0) printf("Positive\n");
	else if (b < 0) printf((b - a) % 2 == 0 ? "Negative\n" : "Positive\n");
}


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

int main() {
    int n;
    cin >> n;
    bool fg = 1;
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        if((x%2==0) && (x%3!=0 && x%5!=0))
            fg = 0;


    }
    if(fg)
        cout << "APPROVED\n";
    else
        cout << "DENIED\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, 0, N) { cin >> a[i]; }
  vector<int> sum(a);
  rrep(i, 0, N - 1) { sum[i] += sum[i + 1]; }

  int ans = 0;
  vector<int> x(a);
  rrep(i, 0, N - 1) { x[i] ^= x[i + 1]; }
  dump(x);

  rep(i, 0, N) {
    int l = -1, r = i;

    while (abs(r - l) > 1) {
      int m = (l + r) / 2;
      int c = x[i] ^ x[m];
      dump(l, r, m, c);
      if ((a[i] ^ c) == sum[m] - sum[i] + a[i])
        r = m;
      else
        l = m;
    }

    int y = abs(i - r) + 1;
    ans += y;
    dump(l, r, ans);
  }

  cout << ans << endl;

  /*
    int l = 0, r = 0;
    int ans = 0;
    rep(i,0,N) {


      r=i;
      int x = 0;
      while (r < N and (x & a[r]) == 0) {
        x ^= a[r];
        r++;
      }

      int y = abs(r - i);
      ans += y * (y + 1) / 2;
      dump(l,r,y,ans);
    }
    cout<<ans<<endl;
  */
  return 0;
}


Measured memory_bytes: 4992
"use strict";

const main = (arg) => {
  const ipt = arg.trim().split("\n");
  let check = {AC: 0, WA: 0, TLE: 0, RE: 0}
  ipt.slice(1).forEach(el => check[el]++);
  for(const key in check){
  	console.log(`${key} x ${check[key]}`);
  }
};
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 37332
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i,n){
        cin>>v[i];
    }
    ll ans=0;
    if(v[0]!=0){cout<<-1<<endl;return 0;}
    for(int i=n-1;i>0;i--){
        if(v[i]>i||v[i-1]+1<v[i]){
            cout<<-1<<endl;
            return 0;
        }
        if(v[i]==v[i-1]+1){
            ans++;
        }else if(v[i]==v[i-1]){
            ans+=v[i-1];
        }else if(v[i-1]>v[i]){
            ans+=v[i];
        }
    }
    cout<<ans<<endl;



    return 0;
}


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

using namespace std;
using ll = long long;

int n, m, q;
int a[52], b[52], c[52], d[52];
int v[11];
int ans;

void brute(int i) {
	if(i == n + 1) {
		int tmp = 0;
		for(int j = 0; j < q; j++) {
			if(v[ b[j] ] - v[ a[j] ] == c[j]) {
				tmp += d[j];
			}
		}

		ans = max(ans, tmp);

		return;
	}
	for(int j = v[i-1]; j <= m; j++) {
		v[i] = j;
		brute(i + 1);
	}
}

int main() {

	scanf("%d %d %d", &n, &m, &q);

	for(int i = 0; i < q; i++) {
		scanf("%d %d %d %d", a + i, b + i, c + i, d + i);
	}

	v[0] = 1;
	brute(1);

	printf("%d\n", ans);
}


Measured memory_bytes: 3828
R, G, B, N = map(int, input().split())

ans = 0

for i in range(N + 1):
    for j in range(N + 1):
        rg = R * i + G * j

        if rg <= N:
            if (N - rg) % B == 0:
                ans += 1

        else:
            break

print(ans)



Measured memory_bytes: 68140
#include <stdio.h>
#include <math.h>
typedef struct vec vec;
struct vec {
    double x, y;
};

static double cross(vec a, vec b) {
    return a.x*b.y - a.y*b.x;
}
int main(void) {
    int i=0,j;
    double s=0;
    vec v[20];
    
    while(scanf("%lf,%lf",&v[i].x,&v[i].y)!=EOF) i++;
    for(j=0;j<i;j++){
        if(j==i-1) s+=cross(v[j],v[0]);
        else s+=cross(v[j],v[j+1]);
    }
    printf("%lf\n",fabs(s/2.0));
 return 0;
}


Measured memory_bytes: 2124
N, M = [int(s) for s in input().split()]
L = [[int(s) for s in input().split()] for _ in range(M)]

L.sort()

c = 0
pa, pb = 0, 0
for a, b in L:
    if pb <= a:
        c += 1
        pa, pb = a, b
    else:
        pa, pb = max(pa, a), min(pb, b)

print(c)


Measured memory_bytes: 21648
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

template<class T=ll>struct Graph{
	int n;
	vector<vector<tuple<ll,T>>>edge;
	Graph(int N=1):n(N){edge.resize(n);}
	void add(ll f,ll t,T c,bool d=false){
		edge[f].emplace_back(t,c);
		if(!d)edge[t].emplace_back(f,c);
	}
	void view(){
		rep(i,n)for(auto&e:edge[i])
			puta(i,"=>",get<0>(e),", cost :",get<1>(e));
	}
};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vi v(n);
	Graph<ll> g(n);
	int a,b;
	rep(i,m){
		cin>>a>>b;
		a--;b--;
		v[a]++;v[b]++;
		g.add(a,b,0);
	}
	int fo=0;
	bool eve=true;
	bool six=false;
	bool fou=false;
	rep(i,n){
		eve&=(v[i]%2==0);
		six|=(v[i]>=6);
		if(v[i]==4)fo++;
	}
	if(!six&&fo==2){
		int pos=-1;
		rep(i,n)if(v[i]==4)pos=i;
		vb vis(n,false);
		vis[pos]=true;
		queue<int> q;
		q.push(get<0>(g.edge[pos][0]));
		vis[get<0>(g.edge[pos][0])]=true;
		while(!q.empty()){
			int p=q.front();q.pop();
			for(auto x:g.edge[p]){
				if(vis[get<0>(x)]==true)continue;
				vis[get<0>(x)]=true;
				q.push(get<0>(x));
			}
		}
		bool all=true;
		rep(i,n)all=all&&vis[i];
		fou=!all;
	}
	Yn(eve&&(fo>2||fou||six));
}



Measured memory_bytes: 8192
#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 = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
#define MSG(a) cout << #a << " " << a << "\n";
 
 
int main(){
    int r; cin >> r;
    cout << 3*r*r <<"\n";
 
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int[] l = new int[n];
    for(int i = 0;i<n;i++){
      l[i] = sc.nextInt();
    }
    int count = 1;
    int now = 0;
    for(int i = 0;i<n;i++){
      now+=l[i];
      if(now>x)break;
      count++;

    }
    System.out.println(count);
  }
}


Measured memory_bytes: 35732
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli

using namespace std ;

#define N 3000000 + 10 

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

lli dp[2001][2001];

int main() 
{
/////////////////////////////////////
    
    fastio;
    
    loopl(i,0,2001)
    dp[i][0] = 1;

    for(lli i=1;i<2001;i++)
    {
        for(lli j=1;j<=i;j++)
        {
            dp[i][j] = (dp[i-1][j] + dp[i-1][j-1])%mod ;
        }
    }

    lli n,k;
    cin>>n>>k;

    for(lli i=1;i<=k;i++)
    {
        cout<<(dp[n-k+1][i]*dp[k-1][i-1])%mod<<endl;
    }

}

Measured memory_bytes: 30080
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  if(a<b)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b,c;
	scanf("%lld%lld%lld",&a,&b,&c);
	puts(a+b==c||a+c==b||b+c==a?"Yes":"No");
}

Measured memory_bytes: 128
/*2019/10/02 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<limits.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
/*
int asc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return -1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return 1;}
int desc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return 1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return -1;}
*/
int main(){
    int n,a[200000];
    ll sum1,sum2;
    sum1=sum2=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum1+=a[i];
    }
    ll min=LLONG_MAX;
    for(int i=0;i<n-1;i++){
        sum2+=a[i];
        sum1-=a[i];
        //printf("%lld %lld\n",sum1,sum2);
        if(labs(sum1-sum2)<min){
            min=labs(sum1-sum2);
        }
    }
    printf("%lld\n",min);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;
int a[105], s[105], p;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    int s0 = 0, s1 = 0;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) s0 += a[i];
    int ans = 0x3f3f3f3f;
    for (int i = 1; i <= n; ++i){
        s0 -= a[i];
        s1 += a[i];
        ans = min(ans, abs(s0 - s1));
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    ll n, m;
    cin >> n >> m;
    ll a[n];
    ll sum = 0;
    for(int i=0;i<m;i++){
        cin >> a[i];
        sum += a[i];
    }

    ll ans = n - sum;
    if(ans<0)
        ans = -1;

    cout << ans << endl;
}

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

int main(void){

    int N,K; cin >>N>>K;

    double ans=0;

    for (int i = 1; i <= N; ++i) {
        double tokuten=i;
        double kakuristu=1.0/N;
        while(tokuten < K){
            tokuten*=2;
            kakuristu *= 1.0/2.0;
        }
        ans += kakuristu;
    }

    printf("%.12f\n", ans);
    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a){
        cin >> x;
        --x;
    }
    int t = 0;
    set<int> s;
    s.insert(0);
    int c = 0;
    while(t != 1){
        c++;
        t = a[t];
        if(s.find(t) != s.end()){
            c = -1;
            break;
        }
        s.insert(t);

    }
    cout << (c == - 1 ? -1 : c) << endl;
}


Measured memory_bytes: 5376