akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;

struct ninja
{
	int b, f, c;
	ninja(int b, int f, int c)
		: b(b), f(f), c(c){}
};
int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int m[100], a[100], b[100];
		for (int i = 0; i < n; ++i)
			scanf("%d%d%d", m + i, a + i, b + i);

		int maxi = 0;
		for (int i = 0; i < n; ++i)
		{
			int sum = 0;
			for (int j = 0; j < n; ++j)
				if (a[j] <= a[i] && a[i] < b[j])
					sum += m[j];
			maxi = max(maxi, sum);
		}
		puts(maxi <= 150 ? "OK" : "NG");
	}

	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<unordered_map>
#include<random>
#include<fstream>
#include<iterator>
#include <numeric>
#include <chrono>

using namespace std;

int main() {

	std::ios::sync_with_stdio(false);
	std::cin.tie(0);

	int n;

	int a;

	cin >> n;

	if (n % 2 == 0)
		cout << n;
	else
		cout<< n * 2;

}

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

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

    long long ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                int num = __gcd(__gcd(i, j), k);
                ans += num;
                //ans += (i == j && j == k ? num : num * 3);
            }
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt=0
for A in range(a+1):
	for B in range(b+1):
		for C in range(c+1):
			if A*500 + B*100 + C*50 == x:
				cnt +=1

print(cnt)


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

typedef long long ll;

int n,m,a,b,c,x,ans;
string s,t,u;

int main(){
  cin>>n>>x;
  int pl[n+1];
  for(int i=0;i<n;i++){
    cin>>pl[i];
  }
  pl[n]=x;
  sort(pl,pl+n+1);

  for(int i=1;i<n+1;i++){
    pl[i]-=pl[0];
  }

  ans=pl[1];
  //cout<<ans<<endl;
  for(int i=2;i<n+1;i++){
    ans=__gcd(ans,pl[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    l = [0]*m
    for j in range(m):
        l[j] = abs(s[i][0] - p[j][0]) + abs(s[i][1] - p[j][1])
    print((l.index(min(l)) +1))

Measured memory_bytes: 3064
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

typedef long long LL;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		const LL INF = 1LL << 60;
		int n = -1, m, l, r, c;
		LL ans = INF;
		cin >> n >> m;
		if (n < 0) return 0;
		vector<vector<pair<int, LL>>> e(n);
		for (int i = 1; i < n; ++i) {
			e[i].emplace_back(make_pair(i - 1, 0));
		}
		for (int i = 0; i < m; ++i) {
			cin >> l >> r >> c;
			--l, --r;
			e[l].emplace_back(make_pair(r, c));
		}
		priority_queue<pair<int, LL>, vector<pair<int, LL>>, greater<>> q;
		q.emplace(make_pair(0, 0));
		vector<LL> cost(n, INF);
		while (!q.empty()) {
			pair<int, LL> top = q.top();
			q.pop();
			if (cost[top.first] <= top.second) continue;
			if (top.first == n - 1) {
				ans = top.second;
				break;
			}
			cost[top.first] = top.second;
			for (auto kv : e[top.first]) {
				auto c = top.second + kv.second;
				if (cost[kv.first] <= c) continue;
				q.emplace(make_pair(kv.first, c));
			}
		}
		cout << (ans < INF ? ans : -1) << endl;
	}
	return 0;
}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int ans = 0;
  REP1(i, n) {
    int tmp = i;
    int cnt = 0;
    while (0 < tmp) {
      cnt++;
      tmp /= 10;
    }
    if (cnt % 2) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int ans;
  ans = max(a+b,a-b);
  ans = max(ans,a*b);
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int W, H, xs, ys, xg, yg, N;
int g[128][128];
int dy[] = {0,-1,0,1}, dx[] = {-1,0,1,0};
int start;

int dfs(int y, int x){
  //  printf("%d %d\n", y, x);
  if(y == yg && x == xg) return 1;
  g[y][x] = 0;
  rep(d, 4){
    int ny = y+dy[d], nx = x+dx[d];
    if(ny < 0 || ny >= H || nx < 0 || nx >= W || g[ny][nx] != start) continue;
    if(dfs(ny, nx)) return 1;
  }
  return 0;
}

int main(){
  while(scanf("%d%d", &W, &H) && W+H){
    scanf("%d%d%d%d%d", &xs, &ys, &xg, &yg, &N); xs--; ys--; xg--; yg--;
    memset(g, -1, sizeof(g));
    rep(i, N){
      int c, d, x, y;
      scanf("%d%d%d%d", &c, &d, &x, &y); x--; y--;
      if(!d){
	rep(i, 2) rep(j, 4) g[i+y][j+x] = c;
      }else{
	rep(i, 4) rep(j, 2) g[i+y][j+x] = c;
      }
    }
    start = g[ys][xs];
    /*    rep(i, H){
      rep(j, W) printf("%d", g[i][j]); puts("");
      }*/

    puts(dfs(ys, xs)?"OK":"NG");
  }

  return 0;
}

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

int main(){
    ll n,d,ans=0;
    cin>>n>>d;
    ll M=d*d;
    for(int i=1;i<=n;i++){
        ll a,b;
        scanf("%lld %lld",&a,&b);
        if(a*a+b*b<=M) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    string A; cin >> A;
    int cnt[26] = {};
    for (auto c : A) cnt[c - 'a']++;

    ll ans = A.size() * (A.size() - 1) / 2 + 1;
    REP(i, 0, 26) ans -= (ll)cnt[i] * (cnt[i] - 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
l, r = map(int, input().split())
min_score = 2019
found = False
for i in range(l, r + 1):
  for j in range(i + 1, r + 1):
    if (i * j) % 2019 == 0:
      print(0)
      found = True
      break
    elif (i * j) % 2019 < min_score:
      min_score = (i * j) % 2019
  if found:
    break
if not found:
  print(min_score)


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

using namespace std;

vector<int> dx = { -1, 1, 0, 0 };
vector<int> dy = { 0, 0, -1, 1 };

void dfs(vector<vector<char>> &field, int x, int y) {
  char kind = field.at(x).at(y);
  // 訪問済みとマーク
  field.at(x).at(y) = 'x';
  // 四方を探索
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    // 同じ種類の樹木なら
    if (0 <= nx && nx < field.size() && 0 <= ny && ny < field.at(0).size() && field.at(nx).at(ny) == kind) {
      dfs(field, nx, ny);
    }
  }
}

void solve(int n, int m, vector<vector<char>> field)
{
  int count = 0;
  
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      // 訪問積みでなければ探索する
      if (field.at(i).at(j) != 'x') {
  		dfs(field, i, j);
        count++;
      }
    }
  }
  
  cout << count << endl;
}

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

    if (N == 0 && M == 0)
      break;

    vector<vector<char>> field(N, vector<char>(M));

    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < M; j++)
      {
        cin >> field.at(i).at(j);
      }
    }

    solve(N, M, field);
  }
}



Measured memory_bytes: 3808
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define maxSize 1024
#define DEBUG 0
class Main
{
  private:
    string s, t;

  public:
    void input()
    {
        cin >> s;
        cin >> t;
#if DEBUG
        cout << "s: " << s << endl;
        cout << "t: " << t << endl;
#endif
    };
    void process()
    {
        bool flag = false;
        int size = s.size();
        while (s.size() == t.size() && size--)
        {
            if (s == t)
            {
                flag = true;
                break;
            }
            s.insert(0, " ");
            s[0] = s[s.size() - 1];
            s.resize(s.size() - 1);
        }
        if (flag)
            cout << "Yes";
        else
            cout << "No";
    };
    void run()
    {
        input();
        process();
    };
    Main()
    {
        run();
    }
};
int main()
{
    new Main();
#if DEBUG
    cout<<endl;
    system("pause");
#endif
    return 0;
}

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


#define ll long long int
#define vll vector<ll>
#define vllv vector<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.14159265358979323846
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
ll fact(ll n){
	
    ll res = 1; 
    for (ll i = 2; i <= n; i++) 
        res = res * i; 
    return res; 
} 
  
int nCr(ll n, ll r) 
{ 
    return fact(n) / (fact(r) * fact(n - r)); 
} 
  
void dfs(vllv &v,ll k,vll &par,vll &dis,ll p)
{
 
    par[k]=p;
    dis[k]=dis[p]+1;
    for(ll i=0;i<v[k].sz;i++){
        if(v[k][i]!=p){
            dfs(v,v[k][i],par,dis,k);
        }
    }
}
bool sortbysec(const pair<string,int> &a,const pair<string,int> &b){return (a.second<b.second);} 


ll ston(string s) 
{ 
    stringstream geek(s); 
    ll x = 0; 
    geek >> x; 
    
  
    return x; 
}
ll pow2(ll n,ll k){ll ans=1;
    while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;}
bool prime(int n){
    int i,j;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}
bool bserch(vector<string> a, string s){
	
	ll l=0,r=a.sz-1,mid;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]==s)return true;
		if(a[mid]<s){
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	return false;
}

bool sortcol( const vector<int>& v1, 
               const vector<int>& v2 ) { 
 return v1[0] < v2[0]; 
} 

void solve()
{
	fast;
	double a,b,h,m,hr,min,ha,ma;
	double phx,phy,pmx,pmy,dist;
	cin>>a>>b>>h>>m;
	hr=h;
	min=m;
	ha=hr*30 + m/2;
	ma=min*6;
	phy=a*cos(ha*pi/180);
	phx=a*sin(ha*pi/180);
	pmy=b*cos(ma*pi/180);
	pmx=b*sin(ma*pi/180);
	dist=sqrt((phx-pmx)*(phx-pmx)+(phy-pmy)*(phy-pmy));
	cout.precision(25);
	cout<<dist;
}

int main()
{
	fast;
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4084
# 2020/07/26
# diverta 2019 Programming Contest - B

# Input
r, g, b, n = map(int,input().split())

ans = 0

# Calc
for ir in range(n+1):
    vr = r * ir 
    if vr > n:
        break

    for ig in range(n+1):
        vg = g * ig 
        if vg > n:
            break
        cb = n - vr - vg
        if cb >= 0 and cb % b == 0:
            ans = ans + 1

# Output
print(ans)


Measured memory_bytes: 67644
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int,input().split()))
# A = list(set(A))
# n = len(A)
A.sort()
# print(A)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if A[i]!=A[j] and A[j]!=A[k] and A[i]+A[j] > A[k]:
                ans += 1
print(ans)

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

int main(){
	string s;
	cin>>s;
	if(s[0]!='A'){
		puts("WA");
		return 0;
	}
	int count=0;
	for(int i=2;i<s.length()-1;i++){
		if(s[i]=='C')count++;
	}
	if(count!=1){
		puts("WA");
		return 0;
	}
	for(char c:s){
		if (c != 'A' && c != 'C' && isupper(c)){
			puts("WA");
			return 0;
		}
	}
	puts("AC");
	
}


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


int N,M;
int p[110000];

// Union Find
    struct UnionFind {
        vector<int> parent;
        int size;
        UnionFind(int n) :parent(n, -1), size(n) {}
        bool unite(int x, int y) {
            x = root(x); y = root(y);
            if (x == y)return false;
            if (sizeOf(x) < sizeOf(y))swap(x, y);
            parent[x] += parent[y]; parent[y] = x; size--;
            return true;
        }
        bool same(int x, int y) { return root(x) == root(y); }
        int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
        int sizeOf(int x) { return -parent[root(x)]; }
    };


int main(){
    cin >> N >> M;
    for(int i=0;i<N;++i) cin >> p[i];
    UnionFind uf(N);
    for(int i=0;i<M;++i){
        int x,y;
        cin >> x >> y;
        uf.unite(x-1,y-1); // 0-indexed
    }

    int ans = 0;
    for(int i=0;i<N;++i){
        if(uf.same(i,p[i]-1)) ans++; // p[i]の位置にiが来ることができるか？ーp[i]==iならtrue,p[i]!=iなら交換可能か？->同じグループか？
    }

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


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

using namespace std;

const string station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  int n;
  while(cin>>n && n!=0) {
    int tmp;
    vector<int> keys;
    for(int i=0; i<n; i++) {
      cin>>tmp;
      keys.push_back(tmp);
    }
    string tmpS, str;
    getline(cin, tmpS);
    getline(cin, str);
    //cout<<"!"<<str<<endl;
    int usingKey = 0;
    string ans;
    //cout<<"!"<<keys.size();
    for(int i=0; i<str.length(); i++) {
      //cout<<"keys="<<keys[usingKey];
      int now = station.find(str[i]);
      ans += station[(now-keys[usingKey]+52)%52];
      //ans += str[i];
      usingKey++;
      //cout<<"nextkeys="<<keys[usingKey];
      if(usingKey == keys.size()) {
	usingKey = 0;
	//cout<<"TRUE";
      }
    }
    //cout<<str<<endl;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1232
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <queue>
#include <iomanip>
#include <tuple>
#include <unordered_set>
#include <unordered_map>

using namespace std;


int main() {
	int k, x;
	cin >> k >> x;

	for (int i = x - k + 1; i < x; i++) {
		cout << i << " ";
	}

	for (int i = x; i < x + k; i++) {
		cout << i << " ";
	}
}


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

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, M;
  cin >> N;
  map<string, int> m;
  string s;
  for (int i = 0; i < N; ++i) {
    cin >> s;
    m[s]++;
  }
  cin >> M;
  for (int i = 0; i < M; ++i) {
    cin >> s;
    m[s]--;
  }
  int ans = 0;
  for (auto const& p: m) {
    ans = max(ans, p.second);
  }
  cout << ans << endl;
  return 0;
}


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

bool red[100005]={0};
int ball[100005]={0};

int main(){
    int n, m;
    cin >> n >> m;
    for(int i=1;i<=n;++i)ball[i] = 1;
    red[1] = true;

    for(int i=0;i<m;++i){
        int x, y;
        cin >> x >> y;
        red[y] |= red[x];
        ball[x]--;
        ball[y]++;
        if(ball[x] == 0)red[x] = false;
    }

    int cnt = 0;
    for(int i=1;i<=n;++i){
        if(red[i])cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

double sisya(double x){
    if (x >= 0){x = (int)(x + 0.5); x = (double)x / 1000;}
    if (x < 0) {x = (int)(x - 0.5); x = (double)x / 1000;}
    
    return x;
}

int main()
{
    int a, b, c, d, e, f;
    double x, y;
    
    while(scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f) != EOF){
        x = (double)(c*e - b*f) / (a*e - b*d) * 1000;
        y = (double)(c*d - a*f) / (b*d - a*e) * 1000;
        
        printf("%.3f %.3f\n", sisya(x), sisya(y));
    }
    
    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <list>
#include <stack>
#include <climits>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#define m7 1000000007
#define m9 1000000009
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second

using namespace std;


const pair<ll, ll> mp = make_pair(-1, -1);
pair<ll,ll> dp[3000][3000];

pair<ll,ll> solve(vector<int>& V, int beg, int end) {
	if (beg == end) {
		dp[beg][end].first = V[beg];
		dp[beg][end].second = 0;
		return make_pair(V[beg], 0);
	}
	if (dp[beg][end] != mp) {
		return dp[beg][end];
	}
	pair<ll, ll> x = solve(V, beg + 1, end);
	pair<ll, ll> y = solve(V, beg, end - 1);
	if (x.second + V[beg] > y.second + V[end]) {
		dp[beg][end].first = x.second + V[beg];
		dp[beg][end].second = x.first;
	}
	else {
		dp[beg][end].first = y.second + V[end];
		dp[beg][end].second = y.first;
	}
	return dp[beg][end];
}
int main()
{
	int n;
	cin >> n;
	vector<int> V(n);
	for (int i = 0; i < n; i++) {
		cin >> V[i];
		for (int j = 0; j < n; j++) {
			dp[i][j] = make_pair(-1,-1);
		}
	}
	solve(V, 0, n - 1);
	cout << dp[0][n - 1].first - dp[0][n - 1].second;
	
	return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> x(n);
    vector<ll> y(m);

    rep(i, 0, n) cin >> x[i];
    rep(i, 0, m) cin >> y[i];
    
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    
    ll sum_x = 0;
    ll sum_y = 0;
    rep(i, 0, n) sum_x = (sum_x + (2 * i - n + 1) * x[i]) % MOD;
    rep(i, 0, m) sum_y = (sum_y + (2 * i - m + 1) * y[i]) % MOD;
    // cout << sum_x << ' ' << sum_y << endl;

    ll ans = (sum_x * sum_y) % MOD;
    cout << ans << endl;
    return 0;
}

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

const ll MOD=1000000007;

ll pow3[100100];

void pow_3(){
    pow3[0]=1LL;
    for(int i=0; i<100010; i++){
        pow3[i+1] = (3LL*pow3[i]) %MOD;
    }
}

string T;
int N;

ll ans (int i){ //Tのi文字目を見る
    //base case
    if(i== (N-1) ){
        if(T.at(i)=='0') return 1;
        else return 3;
    }
    if(T.at(i)=='0') return ans(i+1);
    if(T.at(i)=='1')  return ( 2LL* ans(i+1) + pow3[N-1-i] )%MOD;
}



int main(){
    pow_3();
    cin >> T; N = T.size();
    cout << ans(0) << endl;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 998244353
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 1000010

set<ll>s[16];
int main(){
	IOS;
	tihs;

	ll k;cin>>k;
	rep(i,1,10)s[1].insert(i);
	ll cnt=0;
	rep(i,2,13){
		for(auto k:s[i-1]){
			ll last = k%10;
			rep(j,0,10)if(abs(j-last)<=1){
				s[i].insert(k*10+j);cnt++;
			}
		}
	}
	vll v;
	v.pb(0);
	rep(i,1,13)for(auto j:s[i])v.pb(j);
	sort(all(v));
	cout<<v[k];

	return 0;
}

Measured memory_bytes: 97900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

void work() {
    ll h,w; cin>>h>>w;
    if (h != 1LL && w != 1)
    cout << ((h*w)>>1) + ((h*w)&1LL) << endl;
    else
    cout << "1\n";
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    work();
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue May 14 19:41:33 2019

@author: avin"""

n = int(input())
l = list(map(int, input().split()))

now = l[0]
sums = l[0]
for i in range(1,n):
    if now < l[i]:
        sums += l[i] - now
    now = l[i]
print(sums)

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

int main () {
    long long w, h, x, y;
    cin >> w >> h >> x >> y;

    if (x + x == w && y + y == h) {
        printf("%.10f %c\n", double(w) * double(h) / 2, '1');
    } else {
        printf("%.10f %c\n", double(w) * double(h) / 2, '0');
    }

}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

int main() {
	int a, b, c;
	set<int> color;
	for (int i = 0; i < 3; i++) {
		int d;
		cin >> d;
		color.insert(d);
	}
	cout << color.size() << endl;
	return 0;
}

Measured memory_bytes: 3568
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N= sc.nextInt();
		int K = sc.nextInt();
		int[] x = new int[N];
		for(int i = 0;i < N;i++){
			x[i] = sc.nextInt();
		}
		int[] dis = new int[N-K+1];
		for(int i = 0;i <= N-K;i++){
			dis[i] =Math.min(Math.abs(x[i]) + Math.abs(x[i+K-1] - x[i]),Math.abs(x[i+K-1]) + Math.abs(x[i+K-1] - x[i]));
		}
		if(N == 1){
			System.out.println(Math.abs(x[0]));
			return;
		}
		long ans = 1000000000;
		for(int i = 0;i <= N-K;i++){
			ans = Math.min(ans, dis[i]);
		}
		System.out.println(ans);

	}


}

class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 50136
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  ll place_idx,total_digits;
  while(~scanf("%lld %lld",&place_idx,&total_digits)){
    if(place_idx==0 && total_digits==0) break;
    //1~9 : 0-1+1=1*9
    //10~99 : 99-10+1=2*90
    //100~999 : 999-100+1=3*900
    //1000~9999 : 9999-1000+1=4*9000
    //10000~99999 : 99999-10000+1=5*90000
    //100000~999999 : 999999-100000+1=6*900000
    //1000000~9999999 : 9999999-1000000+1=7*9000000
    //10000000~99999999 : 99999999-10000000+1=8*90000000
    //100000000~999999999 : 999999999-100000000+1=9*900000000
    //1000000000~9999999999 : 9999999999-1000000000+1=10*9000000000
    
    const ll sum[] = {9,2*90,3*900,4*9000,5*90000,
		      6*900000LL,7*9000000LL,8*90000000LL,9*900000000LL,10*9000000000LL,
		      11*90000000000LL};
    ll base = 0;
    int digits = 0;
    ll first = 1;
    for(int i=0;i<10;i++){
      if(base + sum[i] >= place_idx){
	digits = i + 1;
	break;
      }
      base += sum[i];
      first *= 10LL;
    }
    
    int relative_idx = (place_idx - base - 1);

    // printf("place_idx:%d\n",place_idx);
    // printf("relative_idx:%d\n",relative_idx);
    string str = "";
    
    for(ll i=first+relative_idx/digits;i<=first+relative_idx/digits + 100;i++){
      stringstream ss;
      string tmp;
      ss << i;
      ss >> tmp;
      str += tmp;
    }

    cout << str.substr(relative_idx%digits,total_digits) << endl;
  }
}

Measured memory_bytes: 1256
#include <iostream>

using namespace std;
int main(){
    int N,i, j;
    long long int S, K;
    cin >> N;
    S=0;
    for(i=1;i<=N;i++){
        j =  (N/i);
        K = i * (j + 1);
        K *= j;
        K /= 2;
        S += K;
    }
    cout << S;

    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<bitset>
#include<sstream>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int x;
    bool first;
    int i;
    int g;
    while(cin >> x){
        first = true;
        g = 1;
        int ans[10] = {0};
        for(i = 0; x > 1; i++){
            ans[i] = x % 2;
            x /= 2;
        }ans[i] = x;
        rep(j,10){
            if(ans[j] == 1 && first == true){
                cout << g;
                first = false;
            }else if(ans[j] == 1){
                cout << " " << g;
            }g *= 2;
        }cout << endl;
    }
}

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

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}


int G[100][100];
bool seen[100];
int N, M;

void dfs(int v) {
    seen[v] = true;

    for (int i = 0; i < N; i++)
    {
        if (seen[i] == false && G[v][i] == true)
        {
            dfs(i);
        }
   
    }
}
int main() {
    int ans = 0;
    cin >> N >> M;
    vector<int> a(M), b(M);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            G[i][j] = false;
        }
        
    }
    
    for (int i = 0; i < M; i++)
    {
       
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    
    }
    
    for (int i = 0; i < M; i++)
    {
        for (int h = 0; h < N; h++)
        {
           seen[h] = false;
        }
        
        G[a[i]][b[i]] = false;
        G[b[i]][a[i]] = false;
        dfs(0);
        bool result = true;
        for (int j = 0; j < N; j++)
        {
            if (!seen[j])
            {
                result = false;
            }
            
        }
        if (!result)
        {
            ans++;
        }
        G[a[i]][b[i]] = true;
        G[b[i]][a[i]] = true;
    }
    
    cout << ans << endl;


    
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            sS = Console.ReadLine().Trim().Split(' ');
            List<int> lstInp = new List<int>();
            for (int i = 0; i < sS.Length; i++) { lstInp.Add(int.Parse(sS[i])); }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iCnt = 0;
            while (true)
            {
                Boolean iOdd = false;
                for (int i = 0; i < lstInp.Count; i++) { if (lstInp[i] % 2 == 1) { iOdd = true; break; } }
                if (iOdd) { break; }
                for (int i = 0; i < lstInp.Count; i++) { lstInp[i] /= 2; }
                iCnt += 1;
            }

            // 出力
            Console.WriteLine("{0}", iCnt.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> p;
ll INF = (1 << 20);

bool dfs(vector<vector<p>>& g, int u, vector<ll>& dist){
  for(auto& e: g[u]){
    if(dist[e.first] == INF){
      dist[e.first] = dist[u] + e.second;
      if(!dfs(g, e.first, dist)) return false;
    }else if(dist[e.first] != dist[u] + e.second) return false;
  }
  return true;
}

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<p>> g(n);
  for(int i = 0; i < m; i++){
    int l, r, d;
    cin >> l >> r >> d;
    l--; r--;
    g[l].push_back(p(r, d));
    g[r].push_back(p(l, -d));
  }
  vector<ll> dist(n, INF);
  bool flag = true;
  for(int i = 0; i < n; i++){
    if(dist[i] != INF) continue;
    dist[i] = 0;
    flag = flag && dfs(g, i, dist);
  }
  cout << (flag ? "Yes\n" : "No\n");
  return 0;
}


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

#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;

int main(){
    int n,k,l,temp;

    int count =0;
    cin >> n >> k;

    int arr[n]={0};

    for (int i=0;i<k;i++)
        {cin >> l;
        for (int i=0;i<l;i++)
        {cin >> temp;
         arr[temp-1]++;}}


         for (int i=0;i<n;i++)
    {if (arr[i]==0)
        count ++;}
        cout << count << "\n";
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] h = new int[n];

    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
    }

    for (int i = 0; i < (n - 1); i++) {
      if ((h[i + 1] - h[i]) < 0) {
        System.out.println("No");
        return;
      } else if (h[i + 1] > h[i]) {
        h[i + 1]--;
      }
    }

    System.out.println("Yes");

  }
}

Measured memory_bytes: 59792
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  double n, m;
  cin >> n >> m;
  cout << fixed << setprecision(10) << 1.0 / (1.0 / n + 1.0 / m) << endl;
}

Measured memory_bytes: 3816
#include<iostream>
#include <math.h>

using namespace std;

int main() {

	int a, b;
	cin >> a;
	cin >> b;

	int bCopy = b;
	int ketaNum = 1;
	while (bCopy >= 10) {
		ketaNum++;
		bCopy /= 10;
	}

	bCopy = b;

	int connected = (a * pow(10, ketaNum)) + b;

	int flooredSqrt = floor(sqrt(connected));

	if (pow(flooredSqrt, 2) == connected) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <iomanip>
#define PI 3.1415926535
 
using namespace std;
 
string in, t;
double a, b, c;
 
 
int main(){
    cin >> a >> b >> c;
    cout << fixed << setprecision(5) << a*b*sin(c / 360 * 2 * PI) / 2 << endl;
    cout << fixed << setprecision(5) << sqrt(a*a + b*b - 2 * a*b*cos(c / 360 * 2 * PI)) + a + b << endl;
    cout << fixed << setprecision(5) << b*sin(c / 360 * 2 * PI) << endl;
}

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

int main() {
  int N,i,x,y,maxz=-2e9,minz=2e9,maxw=-2e9,minw=2e9;
  cin>>N;
  vector<int> A(N);
  for (i=0;i<N;i++) {
    cin>>x>>y;
    maxz = max(maxz, x+y);
    minz = min(minz, x+y);
    maxw = max(maxw, x-y);
    minw = min(minw, x-y);
  }
  cout<<max(maxz - minz, maxw - minw)<<endl;
  return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int N, A, B, C;
vector<int> l;
int dfs(int count, int a, int b, int c){/*深さ優先探索*/
     int mp[4] = {};
     if(count == N){
          if(a == 0 || b == 0 || c == 0){
               return 1000000000;
          }
          return abs(A - a) + abs(B - b) + abs(C - c) - 30;/*最初の1本にも10ずつ足しているから最後に30引く*/
     }
     mp[0] = dfs(count + 1, a, b, c);
     mp[1] = dfs(count + 1, a + l[count], b, c) + 10;
     mp[2] = dfs(count + 1, a, b + l[count], c) + 10;
     mp[3] = dfs(count + 1, a, b, c + l[count]) + 10;

     return *min_element(mp, mp + 4);
}

int main(){
     int temp;
     cin >> N >> A >> B >> C;
     for(int i = 0; i < N; i++){
          cin >> temp;
          l.push_back(temp);
     }

     cout << dfs(0,0,0,0) << endl;
     return 0;
}

Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 30 , 2019
 * 
 */

#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>
#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(i,x) for(auto (i)=0 ; (i)<(x); ++(i))
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;






auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 

    ivv(a);
    ivv(b);
    cout<<(a>=13?b:(a>=6 and a<=12)?b/2:0)<<endl;


    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

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

#define rep(i,c) for(int i = 0; i < (int)c; ++i)
using llint = long long int ;
using namespace std;

int main(){
    int N;
    int P[200005];
    cin>>N;
    rep(i,N) cin>>P[i];

    int count=0;
    int m=P[0];
    rep(i,N){
        if(m>=P[i]) count++;
        m=min(m,P[i]);
    }
    cout<<count<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int a, p;
  cin >> a >> p;
  p += a * 3;
  cout << p / 2 << '\n';
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A.sort(reverse=True)
    ans=0
    for i in range(N-1):
        ans+=A[(i+1)//2]
    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 33840
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)
#define put putchar
#define pb push_back
#define pop pop_back
using namespace std;
const int N=2e6+5;
int n,m,k,nn,kk;
struct nod{
	int x,y,len;
	nod(int u=0,int v=0,int le=0){x=u;y=v;len=le;}
}ad;
vector<nod>a,d;
char c[2][N];
void add(nod ad){
	if(!ad.x&&!ad.y&&a.size()&&!a.back().x&&!a.back().y)a[a.size()-1].len+=ad.len;else a.pb(ad);
}
int main(){
	scanf("%d%d%d\n%s\n%s",&n,&m,&k,c[0]+1,c[1]+1);
	reverse(c[0]+1,c[0]+n+1);
	reverse(c[1]+1,c[1]+m+1);
	nn=max(n,m);
	fo(i,n+1,nn)c[0][i]='0';
	fo(i,m+1,nn)c[1][i]='0';
	fd(i,1,nn){
		ad=nod(c[0][i]-'0',c[1][i]-'0',1);
		if(ad.x&&ad.y){
			for(kk=k;a.size();){
				if(ad.x&&ad.y){
					if(!a.back().x&&!a.back().y){
						if(kk<=a.back().len){
							if(kk)d.pb(nod(0,0,kk));
							d.pb(nod(1,1,1));
							if(kk<a.back().len)d.pb(nod(0,0,a.back().len-kk));
							a.pop();
							ad=nod(0,0,0);
							break;
						}
						kk-=a.back().len;
						d.pb(a.back());a.pop();
						continue;
					}
					if(!kk){
						d.pb(nod(1,1,1));
						ad=nod(0,0,0);
						break;
					}
					--kk;
					int o=a.back().x;
					d.pb(nod(0,0,1));
					d.pb(o?nod(0,1,1):nod(1,0,1));
					a.pop();
					ad=o?nod(1,0,0):nod(0,1,0);
					continue;
				}
				if(ad.x){
					if(!a.back().x&&!a.back().y){
						d.pb(nod(1,0,1));
						if(a.back().len>1)d.pb(nod(0,0,a.back().len-1));
						a.pop();
						ad=nod(0,0,0);
						break;
					}
					if(a.back().x){
						d.pb(nod(0,0,1));
						a.pop();
						continue;
					}
					//a.back().y
					ad=nod(1,1,0);
					a.pop();
					continue;
				}
				//ad.y
				if(!a.back().x&&!a.back().y){
					d.pb(nod(0,1,1));
					if(a.back().len>1)d.pb(nod(0,0,a.back().len-1));
					a.pop();
					ad=nod(0,0,0);
					break;
				}
				if(a.back().y){
					d.pb(nod(0,0,1));
					a.pop();
					continue;
				}
				//a.back().x
				ad=nod(1,1,0);
				a.pop();
			}
			if(!a.size()){
				if(ad.x&&ad.y){
					if(kk)d.pb(nod(0,0,kk));
					d.pb(nod(1,1,1));
				}else{
					if(ad.x)d.pb(nod(1,0,1));
					if(ad.y)d.pb(nod(0,1,1));
				}
			}
		}else add(ad);
		fd(j,0,d.size()-1)add(d[j]);
		d.clear();
	}
	bool is=0;
	fo(i,0,a.size()-1)
		fo(j,1,a[i].len)
			if(a[i].x)is=1,put('1');
			else (is?put('0'):0);
	put('\n');
	is=0;
	fo(i,0,a.size()-1)
		fo(j,1,a[i].len)
			if(a[i].y)is=1,put('1');
			else (is?put('0'):0);
}

Measured memory_bytes: 18408
import std.stdio, std.array, std.conv, std.string, std.range, std.algorithm;


void main() {
    long a, b, c;
    readf("%d %d %d", &a, &b, &c);

    if ((a <= c && c <= b) || (b <= c && c <= a)) {
        writeln("Yes");
    } else {
        writeln("No");
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, x;
    cin >> n >> x;
    if (n == 2) {
        if (x == 2) printf("Yes\n1\n2\n3\n");
        else printf("No\n");
        return 0;
    }
    if (2 > x || x > 2*n-2) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    queue<int> f;
    if (x == 2) {
        for (int i = 1; i <= 2*n-1; ++i) {
            if (i < x-1 || i > x+2) {
                f.push(i);
            }
        }
    }
    else {
        for (int i = 1; i <= 2*n-1; ++i) {
            if (i < x-2 || i > x+1) {
                f.push(i);
            }
        }
    }
    int cnt = 0;
    ++cnt;
    while(cnt < n-1) {
        int o = f.front();
        f.pop();
        printf("%d\n", o);
        ++cnt;
    }
    if (x == 2) printf("%d\n%d\n%d\n%d\n", x+1, x, x-1, x+2);
    else printf("%d\n%d\n%d\n%d\n", x-1, x, x+1, x-2);
    while(!f.empty()) {
        int o = f.front();
        f.pop();
        printf("%d\n", o);
    }
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
unordered_map<int,bool> mp;
int n,a[14],ans[52],c;

int cal(){
  int res=0;
  for(int i=1;i<13;i++)res=res*5+a[i];
  return res;
}

bool dfs(int s,int d){
  if(d==n)return 1;
  int y=cal();
  if(mp.count(y))return mp[y];
  for(int i=13;i>0;i--){
    if(a[i]&&(s-i)%i==0){
      ans[d]=i;
      a[i]--;
      if(dfs(s-i,d+1))return mp[y]=1;
      a[i]++;
    }
  }
  return 0;
}

int main(){
  while(cin>>n,n){
    memset(a,0,sizeof(a));
    mp.clear();
    c=0;
    for(int i=0,b;i<n;i++)scanf("%d",&b),a[b]++,c+=b;
    if(dfs(c,0)){
      for(int i=n-1;i>=0;i--){
	if(i!=n-1)printf(" ");
	printf("%d",ans[i]);
      }
    }else printf("No");
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3160
import sys
s=str(input())
t=list(input())
string=s
l=1
for i in range(len(t)):
  if s.find(t[i])==-1:
    print(-1)
    sys.exit()
  elif string.find(t[i])==-1:
    l+=1
    string=s[s.find(t[i])+1:]
  else:
    string=string[string.find(t[i])+1:]
  #print(string,l)

print(l*len(s)-len(string))

Measured memory_bytes: 4228
#include<stdio.h>

#define N 200000

int Calc_max_marge(int *,int);

int main(void){
  int A[N],num;
  int i;

  scanf(" %d",&num);
  for(i = 0; i < num; i++){
    scanf(" %d",&A[i]);
  }

  printf("%d\n",Calc_max_marge(A,num));
  
  return 0;
}

int Calc_max_marge(int *A,int num){
  int i;
  int min,max=A[1]-A[0];

  min = A[0];

  for(i = 1; i < num; i++){
    max = max > A[i]-min ? max : A[i]-min;
    min = min < A[i] ? min : A[i];
  }

  return max;
}



Measured memory_bytes: 2632