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

using namespace std;
typedef long long ll;

ll mod = 1e9 + 7;

vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % mod;
}

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % mod;
    if (pow % 2 == 1) a *= x;
    return a % mod;
}

ll calc_div(ll a, ll b) {
    return a * calc_pow(b, mod - 2) % mod;
}

ll calc_comb(ll n, ll r) {
    if (n < r || r < 0)return 0;
    return calc_div(fact[n], fact[r] * fact[n - r] % mod);
}

int main() {
    int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    int times = (x + y) / 3;
    init_fact(1000010);
    cout << calc_comb(times, x - times) << endl;
    return 0;
}

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

int main() {
  string s,t;
  cin>>s>>t;
  int n1,n2;
  n1=s.size();
  n2=t.size();

  vector<vector<ll>> dp(3005, vector<ll> (3005));
  rep(i,3005)rep(j,3005)dp[i][j]=0;

  rep(i,n1)rep(j,n2){
    dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
    if (s[i]==t[j]){
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
    //  cout<<dp[i+1][j+1]<<"i"<<i<<"j"<<j<<endl;
    }
  }
//  int a=dp[n1][n2];
  string ans="";
  while(n1>0 and n2>0){
    if (s[n1-1]==t[n2-1]){
      ans+=s[n1-1];
      n1--;n2--;
    }
    else{
      if (dp[n1][n2]==dp[n1-1][n2]){
        n1--;
      }
      else n2--;
    }
//    cout<<ans<<endl;
  }
  reverse(ans.begin(),ans.end());

cout<<ans;
}


Measured memory_bytes: 73904
N = int(input())
S = input()
tmp = S.count('.')
mini = tmp
def judge(k):
  return bool(S[k]=='.')
def check(k):
  return 1-2*judge(k)
for i in range(N):
  tmp += check(i)
  if tmp < mini:
    mini = tmp
print(mini)

Measured memory_bytes: 3500
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		
		int min = x - k + 1;
		int max = x + k - 1;
		int size = max - min + 1;
		
		String result = String.valueOf(min);
			
		if (size != 1) {
			
			for (int i = 1; i < size - 1; i ++) {
				result = result + " " + String.valueOf(min + i);
			}
		
			result = result + " " + String.valueOf(max);
		}
		
		System.out.println(result);
    
  }
  
}

Measured memory_bytes: 21972
def inpl():
    return list(map(int, input().split()))


def dfs(v, step):
    if f[v] != -1:
        return step
    f[v] = step
    step += 1
    for nv in E[v]:
        # print("now", v, nv, step)
        step = dfs(nv - 1, step)
    d[v] = step
    return step + 1


n = int(input())
E = [[] for i in range(n)]
for _ in range(n):
    tmp = inpl()
    u, k = tmp[:2]
    E[u - 1] = tmp[2:]

d = [-1 for i in range(n)]
f = [-1 for i in range(n)]

step = 1
for v in range(n):
    step = dfs(v, step)

for i in range(n):
    print(i + 1, f[i], d[i])



Measured memory_bytes: 5656
N,K= map(int,input().split())
H = []
for i in range(N):
  H.append(int(input()))
H=sorted(H) 
div=H[N-1]-H[0]
for i in range(0,N-(K-1)):
  a=H[i+K-1]-H[i]
  if div>a:
    div=a
print(div)
    

Measured memory_bytes: 51160
n=int(input())
L=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(i):
        for k in range(j):
            q=L[i];w=L[j];e=L[k]
            # q,w,e=sorted([q,w,e])
            if sum([q,w,e])>max(q,w,e)*2:
                if q!=w and w!=e and e!=q:
                    ans+=1
print(ans)

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

using namespace std;

typedef long long LL;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

typedef vector<int> V;

int main(){
    int N,M;
    map<int,int > X;
    cin>>N>>M;
    REP(i,N){
        int x;cin>>x;X[x]++;
    }
    V mod_single(M,0);
    V mod_double(M,0);
     for(auto &it:X){
        int key=it.first%M;
        mod_double[key]+=it.second/2;
        mod_single[key]+=it.second%2;
    }
    LL res=0;
    REP(i,M){
        int j=(M-i)%M;
        if(i==j){
            res+=mod_single[i]/2;
            mod_single[i]%=2;
        }
        else{
        int y=min(mod_single[i],mod_single[j]);
        res+=y;
        mod_single[i]-=y;
        mod_single[j]-=y;
        }
        //cout<<i<<" "<<j<<" "<<y<<endl;
    }
    REP(i,M){
        mod_single[i]/=2;
    }
    REP(i,M){
        int j=(M-i)%M;
        int y=min(mod_single[i],mod_double[j]);
        res+=2*y;
        mod_single[i]-=y;
        mod_double[j]-=y;
        //cout<<i<<" "<<i<<" "<<2*y<<endl;

    }
    REP(i,M){
        res+=mod_double[i];
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 5760
N = int(input())
flo = list(map(int,input().split()))

def mizuyari(flo):
	cnt = 0
	if len(flo) == 0:
		return 0

	if 0 in flo:
		non = flo.index(0)
		left = flo[:non]
		right = flo[non+1:]
		cnt += (mizuyari(left) + mizuyari(right))
	else:
		minheight = min(flo)
		for i in range(len(flo)):
			flo[i] -= minheight
		cnt += mizuyari(flo) + minheight

	return cnt

ans = mizuyari(flo)
print(ans)

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

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int k, n;
    cin >> k >> n;

    vector<int> V(n), D(n);
    for(int i = 0; i < n; ++i)
        cin >> V[i];

    for(int i = 0; i < n-1; ++i)
        D[i] = V[i+1] - V[i];
    D[n-1] = k - V[n-1] + V[0];

    ll total = 0;
    for(int i = 0; i < n; ++i)
        total += D[i];
    cout << total - *max_element(D.begin(), D.end()) << "\n";
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

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

const int INF = 1e9 + 7;

int main()
{
	IO_OP;
	
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(b, n*a) << endl;
}



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

int main() {
  string S;
  cin >> S;
  
  int count = 0, ans = 0;
  
  for (int i=0; i<S.size(); i++) {
    if (S.at(i) == 'A' || S.at(i) == 'T' || S.at(i) == 'G' || S.at(i) == 'C') {
      count++;
    } else {
      ans = max(ans, count);
      count = 0;
    }
  }
  
  ans = max(ans,count);
  if (ans == 0) cout << count << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  for(int i = 0; i < 10000; i++){
    int x, y;
    scanf("%d%d", &x, &y);
    if(x == 0 && y == 0) break;
    else if(x < y) printf("%d %d\n", x, y);
    else printf("%d %d\n", y, x);
  }
}



Measured memory_bytes: 2684
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,A);
  IN(ll,B);
  IN(ll,C);
  IN(ll,K);
  if(A+B >= K){
    OUT(min(A,K));
  }else{
    OUT(A - (K-A-B));
  }
}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string S;
int main(){
    cin>>S;
    for(ll i=0;i<S.length();i++){
        cout<<"x";
    }cout<<endl;

    return 0;
}

Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split(' '))
S = list(input())

if B<C and C<D:
    f = True
    for i in range(A,D-1):
        if S[i-1]=="#" and S[i]=="#":
            f = False
            break
elif B<D and D<C:
    f = False
    if B<2:
        B = 2
    for i in range(B,D+1):
        if S[i-2]=="." and S[i-1]=="." and S[i]==".":
            f = True
            break
else:
    f = True
    for i in range(B,D-1):
        if S[i-1]=="#" and S[i]=="#":
            f = False
            break
    if f:
        for i in range(A,C-1):
            if S[i-1]=="#" and S[i]=="#":
                f = False
                break
if f:
    print("Yes")
else:
    print("No")


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

#define pb push_back

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
	int n, m, ans = 0, pen = 0;
	vector<int> a, done;
	cin>>n;
	a.assign(n+1, 0);
	done.assign(n+1, 0);
	cin>>m;
	for(int i=0;i<m;i++){
		int num;
		string res;
		cin>>num>>res;
		if(res == "WA"){
			if(!done[num])
				a[num]++;
		}
		else{
			if(!done[num]){
				done[num] = 1;
				ans++;
				pen += a[num];
			}
		}
	}
	cout<<ans<<" "<<pen<<"\n";
	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong a, n, m;
	cin >> a >> n >> m;

	llong beki = -1, lst, maxi;
	llong cp = m;
	bool nine = true;
	while(cp){
		if(cp/10 == 0)
			lst = cp;
		else if(cp%10 != 9)
			nine = false;
		beki++;
		cp /= 10;
	}

	if(nine)
		maxi = lst + beki*9;
	else
		maxi = lst - 1 + beki*9;


	llong ans = 0;
	for(int i = 1; i <= maxi; i++){
		llong num = 1;
		for(int j = 0; j < n && num <= m; j++){
			num *= i+a;
		}
		if(num > m)
			continue;

		int sum = 0;
		while(num){
			sum += num%10;
			num /= 10;
		}

		if(sum == i)
			ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3084
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

int n, d[103][2];

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i)
    cin >> d[i][0] >> d[i][1];
  for (int i = 1; i+2 <= n; ++i)
    if (d[i][0] == d[i][1] && d[i+1][0] == d[i+1][1] && d[i+2][0] == d[i+2][1]) {
      cout<<"Yes\n";
      return 0;
    }
  cout<<"No\n";
}

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

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

  vector<int64_t> a(n * 3);
  rep(i, n * 3) cin >> a.at(i);

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  int64_t ans = 0;
  for (int i = 1; i < n * 2; i += 2) {
    ans += a.at(i);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int n1=n;
    int sum=0;
    while(n){
        sum+=n%10;
        n/=10;
    }
    if(n1%sum==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (true) {
            int w = sc.nextInt();
            int h = sc.nextInt();
            if (w + h == 0) {
                break;
            }

            for (int a=0; a<w; ++a) {
             for (int b=0; b<h; ++b) {
              System.out.print(((a+b)%2==1 ? "." : "#"));
              }
             System.out.println("");
             }
            System.out.println("");
            }
    sc.close();
    }
}



Measured memory_bytes: 33464
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define ll long long

using namespace std;

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> x(n);

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

    int ans = 0;
    for(int i = 0;i < n;i++){
        ans += min(x[i],k-x[i]) * 2;
    }

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

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

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	int n, m;
	string s, t;
	bool f = true;
	
	cin>>n;
	
	if(n == 25) cout<<"Christmas"<<endl;
	else if(n == 24) cout<<"Christmas Eve"<<endl;
	else if(n == 23)cout<<"Christmas Eve Eve"<<endl;
	else cout<<"Christmas Eve Eve Eve"<<endl;
	
	// cout<<<YN(f)<endl;
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())

adj = [[100001 for j in range(n)] for i in range(n)]

for u in range(n):
    x = list(map(int, input().split()))
    for v, c in zip(x[2::2], x[3::2]):
        adj[u][v] = c

unvisited = {v for v in range(n)}

distance = [9900001] * n


def dijkstra(s):
    distance[s] = 0

    while True:
        mincost = 9900001
        for i in unvisited:
            if distance[i] < mincost:
                mincost = distance[i]
                u = i

        if mincost == 9900001:
            break

        unvisited.discard(u)

        for v in unvisited:
            weight_uv = adj[u][v]
            if weight_uv != 100001:
                t_d = distance[u] + weight_uv
                if t_d < distance[v]:
                    distance[v] = t_d



dijkstra(0)

for v, d in enumerate(distance):
    print(v, d)

Measured memory_bytes: 7824
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 400005;
const int MM = 1000000007;

int N, M;

int main()
{
	scanf("%d%d", &N, &M);
	if(N > M) swap(N, M);
	ll ans = 1e9;
	if(M%3) ans = min(ans,(ll)N);
	else ans = 0;
	if(N%3 == 0) ans = 0;

	for(int i = 1; i < N; i++){
		ll l = i, r = N-i;
		ll mn = min({l*M, M/2*r});
		ll mx = max({l*M, (M+1)/2*r});
		ans = min(ans, mx - mn);
	}

	for(int i = 1; i < M; i++){
		ll l = i, r = M-i;
		ll mn = min({l*N, N/2*r});
		ll mx = max({l*N, (N+1)/2*r});
		ans = min(ans, mx - mn);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
using System;
class Program
 {
   	static void Main(string[] args)
        {
    　　	string Kr = Console.ReadLine(); //標準入力
			string S = Console.ReadLine(); //標準入力
		
	       	int K = int.Parse(Kr);
			if(S.Length>K){
     			Console.WriteLine("{0}", S.Substring(0, K)+"...");
            }else{
              
     			Console.WriteLine("{0}", S);
            }
    }
 }

Measured memory_bytes: 27476
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 10010 ;
const int K = 110 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int dp[N][K][2] ;
char s[N] ;
int a[N] ;
int n, m ;

int dfs(int k, int now, int lim) {
//	cout << k << " " << now << " " << lim << endl ;
	if (dp[k][now][lim] >= 0) return dp[k][now][lim] ;
	if (k == m) return dp[k][now][lim] = (now == 0) ;
	int sum = 0, up = lim ? a[k] : 9 ;
//	cout << "in\n" << up << endl  ;
	for (int i = 0; i <= up; i++) {
//		cout << i << endl ;
		sum += dfs(k + 1, (now + i) % n, lim && i == up) ;
		if (sum >= MOD) sum -= MOD ;
	}
	return dp[k][now][lim] = sum ;
}

signed main(){
	scanf("%s%d", s, &n) ;
	m = strlen(s) ;
	for (int i = 0; i < m; i++) a[i] = s[i] - '0' ;
	ass(dp, -1) ;
	printf("%d\n", (dfs(0, 0, 1) + MOD - 1) % MOD) ; // 0 is incorrect
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 9728
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
class shop {
public:
	char stamp;
	ll num[3];
	ll dummy;
	shop():dummy(-1) {

	}
};

int main() {
	int time;
	cin >> time;
	shop *streat;
	streat = new shop[time + 1];
	for (int i = 0; i < 3; ++i) {
		streat[0].num[i] = 0;
	}
	char dummy;
	for (int i = 1; i <= time; ++i) {
		cin >> dummy;
		for (int j = 0; j < 3; ++j) {
			streat[i].num[j] = streat[i-1].num[j];
		}
		if (dummy == 'J') {
			++streat[i].num[0];
		}
		else if (dummy == 'O') {
			++streat[i].num[1];
		}
		else {
			++streat[i].num[2];
		}
		streat[i].stamp = dummy;
	}
	ll origin = 0;
	ll date;
	for (int i = time - 2; i >= 1; --i) {
		if (streat[i].stamp == 'J') {
			date = 0;
			for (int j = i + 1; j <= time; ++j) {
				if (streat[j].dummy != -1) {
					date += streat[j].dummy;
					break;
				}
				if (streat[j].stamp == 'O') {
					date += streat[time].num[2] - streat[j].num[2];
				}
			}
			streat[i].dummy = date;
			origin += date;
		}
	}
	date = 0;
	for (int j = 1; j <= time; ++j) {
		if (streat[j].stamp == 'O') {
			date += streat[time].num[2] - streat[j].num[2];
		}
	}
	ll answer = date;
	date = 0;
	for (int j = time; j >= 1; --j) {
		if (streat[j].stamp == 'O') {
			date += streat[j].num[0];
		}
	}
	answer = max(answer, date);
	for (int i = 2; i < time; ++i) {
		answer = max(answer, streat[i].num[0] * (streat[time].num[2] - streat[i].num[2]));
	}
	cout << origin + answer<< endl;
	return 0;
}

Measured memory_bytes: 7000
import collections
S =[i for i in input()]
K = int(input())
a = 1
b = []
c = []
SS = len(S)
result = 0
if S[0] != S[-1]:
  try:
    for j in range(len(S)):
      if S[j] == S[j+1]:
        a += 1
      else:
        b.append(a)
        a = 1
  except:
    b.append(a)
  for k in b:
    result += k//2
  print(result*K)
elif len(collections.Counter(S)) == 1:
  print(len(S)*K//2)
else:
  result2 = 0
  for j in range(len(S)):
    if S[j] == S[j + 1]:
      a += 1
    else:
      c.append(a)
      a = 1
      break
  S2 = S[c[0]:]
  try:
    for j in range(len(S2)):
      if S2[j] == S2[j + 1]:
        a += 1
      else:
        c.append(a)
        a = 1
  except:
    c.append(a)
  S = S+S
  S = S[c[0]:-(SS-c[0])]
  try:
    a = 1
    for j in range(len(S)):
      if S[j] == S[j+1]:
        a += 1
      else:
        b.append(a)
        a = 1
  except:
    b.append(a)
  for k in b:
    result += k//2
  for l in c:
    result2 += l//2
  print(result*(K-1)+result2)


Measured memory_bytes: 3316
n, m, c = map(int, input().split())
list_A = list(map(int, input().split()))
list_B = [ list(map(int,input().split(" "))) for i in range(n)]

ans = 0

for i in range(n):
    l = list_B[i]
    k = c
    for j in range(m):
        k += list_A[j]*l[j]
    if k > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
ans = 'Yes'

S = list(raw_input())

if S.count('N') == 0 and S.count('S') != 0:
  ans = 'No'

elif S.count('W') == 0 and S.count('E') != 0:
  ans = 'No'

elif S.count('S') == 0 and S.count('N') != 0:
  ans = 'No'

elif S.count('E') == 0 and S.count('W') != 0:
  ans = 'No'

print ans

Measured memory_bytes: 2568
import math

A, B, H, M = (int(x) for x in input().split())

minuteAngle = math.radians(M * 6)

hourAngle = math.radians(M * 30 / 60 + H * 30)

angleC = abs(hourAngle - minuteAngle)

print(math.sqrt((A ** 2) + (B ** 2) - (2 * A * B * math.cos(angleC))))


Measured memory_bytes: 9380
N, M = gets.split.map(&:to_i)
scs = Array.new(M) { s, c = gets.chomp.split; [s.to_i.pred, c] }

min = 10 ** (N - 1)
min = min == 1 ? 0 : min
max = 10 ** N - 1

if scs.empty?
  puts(min)
  exit
end

rval = (min..max).find do |n|
  nc = n.to_s
  scs.all? do |s, c|
    nc[s] == c
  end
end

puts(rval ? rval : '-1')


Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <limits>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#include <cmath>
#include <complex>

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

const int INFL = (int)1e9;
const ll INFLL = (ll)1e18;
const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loopll(i, n) for(ll i = 0; i < (ll)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopll1(i, n) for(ll i = 1; i <= (ll)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = (ll)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define Looprll1(i, n) for(ll i = (ll)n; i >= 1; i--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(i, vector.size()) { cout << vector[i] << " "; } cout << endl;
#define printmx(matrix) Loop(i, matrix.size()) { Loop(j, matrix[i].size()) { cout << matrix[i][j] << " "; } cout << endl; }
#define rndf(d) (ll)((double)(d) + (d >= 0 ? 0.5 : -0.5))
#define floorsqrt(x) ((ll)sqrt((double)x) + ((ll)sqrt((double)x) * (ll)sqrt((double)x) <= (ll)(x) ? 0 : -1))
#define ceilsqrt(x) ((ll)sqrt((double)x) + ((ll)x <= (ll)sqrt((double)x) * (ll)sqrt((double)x) ? 0 : 1))
#define rnddiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) * 2 >= (ll)(b) ? 1 : 0))
#define ceildiv(a, b) ((ll)(a) / (ll)(b) + ((ll)(a) % (ll)(b) == 0 ? 0 : 1))
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)

/*******************************************************/

int main() {
	int n; cin >> n;
	vll a(n); Loop(i, n) cin >> a[i];
	vll b(n);
	b.back() = a.back();
	ll ans = b.back();
	Loopr(i, n - 1) {
		b[i] = b[i + 1] - 1;
		if (b[i] == a[i]) continue;
		else if (b[i] < a[i]) {
			ans += a[i];
			b[i] = a[i];
		}
		else {
			ans = -1;
			break;
		}
	}
	if (b[0] != 0) ans = -1;
	cout << ans << endl;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    int a,b;
    cin>>a>>b;
    cout<<max(0,a-2*b)<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;

int main() {
  int N, M, T;
  cin >> N >> M >> T;
  int a[N];
  rep(i, N) cin >> a[i];
  a[N] = T + M;
  int ans = a[0] - M;
  for (int i = 0; i < N; i++)
    ans += max(0, a[i + 1] - a[i] - 2 * M);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3100
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (map.containsKey(a)) {
				map.put(a, map.get(a) + 1);
			} else {
				map.put(a, 1);
			}
		}
		sc.close();

		int max1 = 0;
		int max2 = 0;
		while (map.size() > 0) {
			int key = map.lastKey();
			int val = map.get(key);
			map.remove(key);
			if (val < 2) {
				continue;
			}
			if (max1 == 0) {
				max1 = key;
				if (val < 4) {
					continue;
				}
			}
			if (max2 == 0) {
				max2 = key;
				break;
			}
		}
		System.out.println((long) max1 * max2);
	}
}


Measured memory_bytes: 61296
def examB():
    N = I()
    ansC = [(i+1) for i in range(N)]
    k = 0
    while(len(ansC)>=2):
        cur = []
        for i in ansC:
            if i % 2 == 0:
                cur.append(i // 2)
        ansC = cur
        k +=1
        if len(ansC)==1:
            break
    ans = 2**k
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


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

int main() {
    int k, n, total = 0, max = 0;
    cin >> k >> n;
    vector<int> v(n), u(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    for (int i = 0; i < n; ++i) {
        u[i] = (i == 0 ? v[0] + k - v[n - 1] : v[i] - v[i - 1]);
        if (u[i] > max)
            max = u[i];
        total += u[i];
    }
    cout << total - max;
}


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

int main(){

  int H,W,N;
  cin>>H;	
  cin>>W;
  cin>>N;
  if(H>W){

	if(N%H==0)cout<<N/H;
    else cout<<N/H+1;
  } 
  else {
    if(N%W==0)cout<<N/W;
    else cout<<N/W+1;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap_str(int *a, int *b){
  int temp = *a;
  *a = *b;
  *b = temp;
}

void sort_str(int *s, int n){
  int i, j;
  
  for(i = 0; i < n; i++){
    for(j = n - 1; j > i; j-- ){
      if(s[j - 1] > s[j])
        swap_str(&s[j - 1], &s[j]);
    }
  }
}

int main(){
  int n;
  int i;
  int a[101];
  int sum_a = 0;
  int sum_b = 0;
  int t = 0;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  
  sort_str(a, n);
  
  for(i = n - 1; i >= 0; i--){
    if(t == 0){
      sum_a += a[i];
      t = 1;
    }
    else if(t == 1){
      sum_b += a[i];
      t = 0;
    }
  }
  
  printf("%d\n", sum_a - sum_b);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
const int MOD = 1000000007;
const int N = 100005;
const int M = 1000005;

#define ll                      long long int
#define loop(i,a,b)             for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)            for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)            for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)            for(int i=(int)a;i>=(int)b;--i)
#define pb                      push_back
#define F                       first
#define S                       second
#define mp                      make_pair
#define RALL(x)                 x.rbegin(),x.rend()
#define ALL(x)                  x.begin(),x.end()
#define MAX                     1e9
#define MIN                     -1e9
#define max(x,y)                (x>y)?x:y
#define min(x,y)                (x<y)?x:y
#define mid(l,r)                (l+(r-l)>>1)
#define mina(a)                 *min_element(a.begin(), a.end())
#define maxa(a)                 *max_element(a.begin(), a.end())
#define PI                      acos(-1.0)

typedef  map<string,int>         msi;
typedef  map<int,int>            mii;
typedef  map<ll, ll>             mll;
typedef  map<char,int>           mci;
typedef  map<int,string>         mis;
typedef  pair<int,int>           pii;
typedef  pair<string, int>       psi;
typedef  pair<string, string>    pss;
typedef  vector<int>             vi;
typedef  vector<string>          vs;
typedef  vector<char>            vc;
typedef  vector<bool>            vb;
typedef  vector< pii >           vii;

int h[100005]={0};
int n,k;
int dp[100005];

// int mink(int id)
// {
//     int s = max(0,id-k);
//     int ans=INT_MAX;
//     while(s<id)
//     {
//         ans = min(ans, dp[s++]);
//     }
//     return ans;
// }


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

    cin>>n>>k;
    loop(i,0,n)
        cin>>h[i];
    dp[0]=0;
    dp[1] = abs(h[1]-h[0]);
    loop(i,2,n)
    {
        // dp[i] = mink(i);
        int s = max(0,i-k);
        // cout<<"s="<<s<<endl;
        int ans = INT_MAX;
        while(s<i)
        {
            ans = min(ans, dp[s]+abs(h[i]-h[s]));
            // cout<<"s="<<s<<" ans="<<ans<<endl;
            s++;
        }
        dp[i] = ans;
        // cout<<"i="<<i<<" dp[i]="<<dp[i]<<endl;
    }
    // cout<<"1 "<<dp[1]<<" 2 "<<dp[2]<<" 3 "<<dp[3]<<endl;
    cout<<dp[n-1];


    return 0;
}

Measured memory_bytes: 1024
function Main(input) {
    // console.log(input);
    var tmp = input.split("\n");
    tmp = tmp[0].split(" ");
    var a = parseInt(tmp[0]);
    var b = parseInt(tmp[1]);

    var score = 0;
    if (a >= b) {
        score += a;
        a -= 1;
    } else {
        score += b;
        b -= 1;
    }
    if (a >= b) {
        score += a;
        a -= 1;
    } else {
        score += b;
        b -= 1;
    }
    console.log(score)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 12732
A,B,C = map(int, input().split())

if A==B:
    if A!=C:
        print('Yes')
    else:
        print('No')
elif A==C:
    if A!=B:
        print('Yes')
    else:
        print('No')

elif B==C:
    if A!=C:
        print('Yes')
    else:
        print('No')
else:
    print('No')


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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

const int INF = 10000000;

int main()
{
    int n;
    while (n = in()){
        int town[16][16];
        rep(i, 16) rep(j, 16) town[i][j] = INF;
        rep(i, 16) town[i][i] = 0;
        int maxi = 0;
        rep(i, n){
            int f, t, c;
            f = in();
            t = in();
            c = in();
            maxi = max(maxi, f);
            maxi = max(maxi, t);
            town[t][f] = town[f][t] = c;
        }
        n = maxi + 1;
        rep(k, n) rep(i, n) rep(j, n) town[i][j] = min(town[i][j], town[i][k] + town[k][j]);
        vector<pair<int, int> > costs;
        rep(i, n){
            int cost = 0;
            rep(j, n){
                cost += town[i][j];
            }
            costs.push_back(make_pair(cost, i));
        }
        sort(costs.begin(), costs.end());
        printf("%d %d\n", costs[0].second, costs[0].first);
    }
    return (0);
}

Measured memory_bytes: 1192
#include<cstdio>
#include<cmath>
#include<vector>
#include<iostream>
using namespace std;

int main(){
	int n,m,x;
	vector<int> a;
	scanf("%d %d %d",&n,&m,&x);
	for(int i=0;i<m;i++){
		int tmp;
		cin >> tmp;
		if(tmp > x){
			cout << min(i,m-i);
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;



int main()
{
    long long int n , total =0;
    cin >> n;
    for(int i=n; i>=1; i--)
    {
        if(i%3==0||i%5==0)
            continue;
        else
            total += i;
    }

    cout << total;
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <complex>
using namespace std;

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

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

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

bool equals(set<P> a,set<P> b){
  if(a.size() != b.size()) return false;

  set<P>::iterator iterA = a.begin();
  set<P>::iterator iterB = b.begin();
  int diffX = (iterA->first) - (iterB->first);
  int diffY = (iterA->second) - (iterB->second);

  while(iterA != a.end()){
    if((iterA->first) - (iterB->first) != diffX ||
       (iterA->second) - (iterB->second) != diffY){
      return false;
    }
    iterA++;
    iterB++;
  }
  return true;
}

int main(){
  int T;
  string tmp;
  cin>>T;
  getline(cin,tmp);

  while(T--){
    string a,b;
    getline(cin,a);
    getline(cin,b);
    getline(cin,tmp);

    set<P> aset;
    P p(0,0);
    aset.insert(p);

    rep(i,a.length()){
      p.first += dx[a[i] - 'a'];
      p.second += dy[a[i] - 'a'];
      aset.insert(p);
    }

    /*
    for(set<P>::iterator iter=aset.begin();iter!=aset.end();iter++){
      cout<<(iter->first)<<","<<(iter->second)<<endl;
    }
    cout<<"--\n";
    */

    bool flg = false;

    rep(i,6){
      set<P> bset;
      bset.clear();
      p = P(0,0);
      bset.insert(p);
      rep(j,b.length()){
        p.first += dx[((int)b[j] - 'a' + i) % 6];
        p.second += dy[((int)b[j] - 'a' + i) % 6];
        bset.insert(p);
      }
      /*
      if(b.length() > 0 && b[0] == 'b'){
        for(set<P>::iterator iter=bset.begin();iter!=bset.end();iter++){
          cout<<(iter->first)<<","<<(iter->second)<<endl;
        }
        cout<<endl;
      }
      */

      if(equals(aset,bset)){
        flg = true;
        break;
      }
    }

    if(flg){
      cout<<"true\n";
    }
    else{
      cout<<"false\n";
    }
  }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{
    class Program
    {
        static void Main(string[] args)
        {            
            int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');

            List<int> upStairs = new List<int>();
            
            upStairs.Add(-1);

            for(int i = 0; i < s.Length - 1; i++)
            {
                if(int.Parse(s[i]) < int.Parse(s[i + 1]))
                {
                    upStairs.Add(i);
                }
            }

            upStairs.Add(n - 1);

            int answer = 0;

            for(int i = 0; i < upStairs.Count - 1; i++)
            {
                if(upStairs[i + 1] - upStairs[i] > answer)
                {
                    answer = upStairs[i + 1] - upStairs[i];
                }
            }

            Console.WriteLine(answer - 1);
        }
    }
}


Measured memory_bytes: 22620
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL MOD = 1000000007LL;
LL a[5001];
LL dp[5001][5001];
LL dp2[5001];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> a[i];
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= K; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= a[i]) (dp[i][j] += dp[i - 1][j - a[i]]) %= MOD;
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= K; j++) {
			dp2[j] = dp[N][j];
			if(j>=a[i]) dp2[j] = (dp2[j] - dp2[j - a[i]] + MOD) % MOD;
		}
		bool ok = 0;
		for (int j = max(K - a[i], (LL)0); j < K; j++) {
			if (dp2[j]) {
				ok = 1;
				break;
			}
		}
		if (!ok) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 195712
N, T = map(int, input().split())

c = []
t = []

for i in range(N) : 
    a, b = map(int, input().split())
    if b <= T : 
        c.append(a)
        t.append(b)

if len(c) == 0 :
    print("TLE")
else : 
    print(min(c))

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




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




void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


int main() {


  cout<<fixed<<setprecision(10);

  ll a,b,c; cin>>c>>a>>b;

  cout<<a*c/2<<endl;



}

//


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}



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

    if(s==u)cout << a-1 << " " << b << endl;
    else cout  << a << ' ' <<  b-1 << endl;

}



Measured memory_bytes: 3604
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll a[200];
ll ans;

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

  rep( i, N ) {
    std::cin >> a[i];

    if( (i+1)&1 && a[i]&1 )
      ++ans;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n;
	cin >> n;
	veci p(n);
	rep(i, n) cin >> p[i];
	int ans = 0;
	for (int i = 0; i < n - 1; i++)
	{
		if (i + 1 == p[i])
		{
			ans++;
			swap(p[i], p[i + 1]);
		}
	}
	if (p[p.size() - 1] == n)
		ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
A, B, C, K = list(map(int, input().split()))
D = 0
if K <= A:
    print(K)
else:
    D += A
    K -= A
    if K > B:
        K -= B
        if K >= C:
            D -= C
            print(D)
        else:
            D -= K
            print(D)
    else:
        print(D)

Measured memory_bytes: 9196
<?php

$nums = explode(' ', trim(fgets(STDIN)));
$x1 = $nums[0];
$y1 = $nums[1];
$x2 = $nums[2];
$y2 = $nums[3];

$answer = sqrt(($x2 - $x1) * ($x2 - $x1) + ($y2 - $y1) * ($y2 - $y1));

echo $answer . "\n";



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

using namespace std;
using ll = long long;

int main(){
    string s;cin >> s;
    string t;cin >> t;
    vector<vector<int>> vec(26, vector<int>(s.size()));
    vector<vector<int>> ruiseki(26, vector<int>(1));
    ll ans = 0;
    map<char, int> q,p;
    for(auto a : s){
        q[a] = 1;
    }
    for(auto a : t){
        p[a] = 1;
    }
    for(int a = 0;a < 26;a++){
        if(p[a+'a'] == 1 && q[a+'a'] == 0){
            cout<<-1<<endl;
            return 0;
        }
    }
    for(int i = 0;i < s.size();i++){
        vec.at(s.at(i)-'a').at(i)++;
    }
    for(int i = 0;i < 26;i++){
        for(int j = 0;j < s.size();j++){
            ruiseki.at(i).push_back(ruiseki.at(i).back() + vec.at(i).at(j));
        }
    }
    int now = 0;
    for(auto c : t){
    //    cout<<ans<<endl;
        if(ruiseki.at(c-'a').back() < ruiseki.at(c-'a').at(now)+1){
            ans += s.size() - now;
            now = 0;
        }
  //      cout<<ans<<endl;
        int ok = s.size();
        int ng = 0;
        while(ok - ng > 1){
          //  cout<<ok<<" "<<ng<<endl;
            int mid = (ok+ng)/2;
            if(ruiseki.at(c-'a').at(mid) >= ruiseki.at(c-'a').at(now)+1){
                ok = mid;
            }else{
                ng = mid;
            }
        }
    //    cout<<ok<<"A"<<endl;
        ans += ok - now;
        now = ok;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 21420
#include <iostream>
#include <vector>
#include <cmath>
int main() {
	int n;
	std::cin >> n;
	std::vector<int> vec(n + 2, 0);
	for (auto i = 1; i <= n; ++i) {
		std::cin >> vec[i];
	}
	int sum{ 0 };
	for (int i = 1; i < vec.size(); ++i) {
		sum += std::abs(vec[i] - vec[i - 1]);
	}
	for (auto i = 1; i <= n; ++i) {
		std::cout << sum - std::abs(vec[i] - vec[i - 1]) - std::abs(vec[i] - vec[i + 1]) + std::abs(vec[i - 1] - vec[i + 1]) << '\n';
	}
}

Measured memory_bytes: 2296