akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll             long long int
#define lb             lower_bound
#define fi             first
#define ub             upper_bound
#define se              second
#define mp             make_pair
#define vll            vector<ll>
#define mod            1000003
#define endl            "\n"
#define fast           ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb             push_back
#define sz               size()
#define all(v)         v.begin(),v.end()
#define allr(v)        v.rbegin(),v.rend()
#define inp(V,n)       for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)       {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.second >b.second);
    }
    else
        return (a.fi<b.fi);
}
int main()
{ int t=1;
   //cin>>t;
   while(t--)
  { ll n,i,j,k;
    string s;
    cin>>s;ll c=0;vll v;

    for(i=0;i<s.size();i++)
    { if(s[i]=='R')
         c++;
         else{
            v.pb(c);
            c=0;
         }

    }
    v.pb(c);
    sort(allr(v));
    cout<<v[0]<<endl;



  }
return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    sort(S.begin(),S.end());
    
    S.erase(unique(S.begin(),S.end()),S.end());
    
    if(S.size() == 3){
        cout << "Three" << endl;
    }else{
        cout << "Four" << endl;
    }
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 1e5 + 5 ;
char s[105] ;
int main()
{
	scanf("%s" , s) ;
	int len = strlen(s) ;
	int ans = 0 ;
	for(int i = 0 ; i <= (len - 1) / 2 ; i ++)
	  if(s[i] != s[len - 1 - i])
	    ans ++ ;
	printf("%d\n" , ans) ;
}

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

int main() {
	vector <int> a(5);
	int minOne = 10;
	int minOneYoso = 0;
	int ans = 0;
	for (int i = 0; i < 5; i++) {
		cin >> a.at(i);
		if (a.at(i) % 10 != 0) {
			if (minOne > a.at(i) % 10) {
				minOne = a.at(i) % 10;
				minOneYoso = i;
			}
		}
	}

	for (int i = 0; i < 5; i++) {
		ans += a.at(i);
		if (i != minOneYoso && a.at(i) % 10 != 0) {
			ans += 10- (a.at(i) % 10);
		}
	}

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

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
//cin.tie(0);
//ios::sync_with_stdio(false);
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,K,Q,h,i,j,ans=mod;cin>>n>>K>>Q;
	//最小値を決め打ちする
	//最大値をにぶたんする
	vector<int>a(n);
	for(i=0;i<n;i++){cin>>a[i];}
	vector<pair<int,int>>aa(n);
	for(i=0;i<n;i++){aa[i]=mp(a[i],i);}
	SO(aa);
	for(h=0;h<n;h++){
		int syo=a[h];
		vector<int>bas(n);
		int ge=0;
		for(i=0;i<n;i++){
			if(a[i]<syo){ge++;}
			bas[i]=ge;
		}
		ge++;
		vector<vector<int>>ryo(ge);
		int tota=0;
		for(i=0;i<n;i++){
			if(aa[i].fir<syo){continue;}
			ryo[bas[aa[i].sec]].pub(aa[i].fir);
		}
		vector<int>toru;
		for(i=0;i<ge;i++){
			SO(ryo[i]);
			for(j=0;j<K-1;j++){
				if(ryo[i].size()==0){break;}
				ryo[i].pob();
			}
			for(auto it:ryo[i]){
				toru.pub(it);
			}
		}
		SO(toru);
		if(Q<=toru.size()){mineq(ans,toru[Q-1]-syo);}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc113_c
{
	class Program
	{
		static void Main(string[] args)
		{
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			List<int>[] list = new List<int>[x[0]];
			for (int i = 0; i < x[0]; i++) list[i] = new List<int>();
			Tuple<int, int>[] city = new Tuple<int, int>[x[1]];
			for (int i = 0; i < x[1]; i++)
			{
				int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
				list[a[0] - 1].Add(a[1]);
				city[i] = new Tuple<int, int>(a[0], a[1]);
			}
			for (int i = 0; i < x[0]; i++)
			{
				int[] arr = list[i].ToArray();
				Array.Sort(arr);
				list[i] = arr.ToList();
			}
			for (int i = 0; i < x[1]; i++)
			{
				Console.WriteLine(city[i].Item1.ToString("D6") + (list[city[i].Item1 - 1].BinarySearch(city[i].Item2) + 1).ToString("D6"));
			}
		}
	}
}

Measured memory_bytes: 38840
def p_a():
    M, D = map(int, input().split())
    ans = 0

    for m in range(M + 1):
        for d in range(D + 1):
            d1 = d // 10
            d2 = d -10*d1

            if d1 >= 2 and d2 >= 2 and m == d1 * d2:
                ans += 1
                
    print(ans)

if __name__ == '__main__':
    p_a()

Measured memory_bytes: 39024
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,s=0; cin>>n; 
    vi a(n);
    for (int &i: a) { cin>>i; s += i; }
    int m; cin>>m;
    while (m--){
        int p,x;
        cin >> p >> x; 
        cout << (s+x-a[p-1]) << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3612
//https://atcoder.jp/contests/abc162/tasks/abc162_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
//o(1)
int main() {
  ll N; cin>>N;
  auto sum_func = [&](ll d){
    ll f=d;
    ll l=(N/d)*d;
    ll num=N/d;
    return (f+l)*num/2;
  };
  ll ans=sum_func(1)-sum_func(3)-sum_func(5)+sum_func(15);
  cout<<ans<<endl;
  return 0;
}
int main_() {
  ll N;cin>>N;
  ll ans=0;
  FOR(i,1,N+1){
    if(i%3==0||i%5==0){
    }else{
      ans += i;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 2e5+9;
const ll INF = 1LL<<60;

template<class T> struct SegmentTree {
    using func = function<T(T, T)>;
private:
    int n;
    T ie;
    func operation;
    func updater;
    vector<T> node;

    T _query(int l, int r, int k, int kl, int kr) {
        if(kr <= l || r <= kl)
            return ie;
        if(l <= kl && kr <= r)
            return node[k];
        T v1 = _query(l, r, 2*k+1, kl, (kl+kr)/2);
        T v2 = _query(l, r, 2*k+2, (kl+kr)/2, kr);
        return operation(v1, v2);
    }

public:
    void init(int _n, T _ie, func _operation, func _updater) {
        n = 1; while(n < _n) n *= 2;
        ie = _ie;
        operation = _operation;
        updater = _updater;
        node.assign(2*n-1, ie);
    }

    void update(int i, T x) {
        i += n-1;
        node[i] = updater(node[i], x);
        while(i > 0) {
            i = (i-1) / 2;
            node[i] = operation(node[2*i+1], node[2*i+2]);
        }
    }

    T query(int l, int r) {
        return _query(l, r, 0, 0, n);
    }
};

int n;
int h[N];
ll a[N];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> h[i], h[i]--;
    for(int i = 0; i < n; i++)  cin >> a[i];
    SegmentTree<ll> st;
    auto operation = [](ll a, ll b){ return max(a, b); };
    auto updater = [](ll a, ll b){ return b; };
    st.init(n, -INF, operation, updater);

    for(int i = 0; i < n; i++) {
        ll beautiful = max(0LL, st.query(0, h[i])) + a[i];
        st.update(h[i], beautiful);
    }

    cout << st.query(0, n) << endl;
}

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

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

    vector<string> s(n);
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> s[i] >> p[i];
    }

    map<string, map<int, int>> score;
    for(int i=0; i<n; i++){
        score[s[i]].emplace(-p[i],i);// not insert (since it unwantedly updates the value)
    }

    for(auto map_sm : score){
        for(auto map_ii : map_sm.second){
            cout << map_ii.second + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
def mi():
    return map(int, input().split())

def main():
    N, K = mi()
    R, S, P = mi()
    T = input()
    pt = 0
    my_choices = ['']*N

    for i in range(K):
        tmp = T[i::K]
        for j in range(len(tmp)):
            if j == 0:
                if tmp[j] == 'r':
                    my_choices[i] = 'p'
                    pt += P
                if tmp[j] == 's':
                    my_choices[i] = 'r'
                    pt += R
                if tmp[j] == 'p':
                    my_choices[i] = 's'
                    pt += S
            else:
                if tmp[j] == 'r' and my_choices[i+(j-1)*K] != 'p':
                    my_choices[i+j*K] = 'p'
                    pt += P
                if tmp[j] == 's' and my_choices[i+(j-1)*K] != 'r':
                    my_choices[i+j*K] = 'r'
                    pt += R
                if tmp[j] == 'p' and my_choices[i+(j-1)*K] != 's':
                    my_choices[i+j*K] = 's'
                    pt += S

    print(pt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 43632
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
#define PI 3.14159265358979323846
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
 
int dat[600000];
 
class Segment{
    public :
        int n;
        void init(int n_){
            n=1;
            while(n<n_)n*=2;
            for(int i=0;i<2*n-1;++i)dat[i]=-INT_MAX;
        }
 
        void update(int k,int a){
            k+=n-1;
            dat[k]=a;
            while(k>0){
                k=(k-1)/2;
                dat[k]=max(dat[k*2+1],dat[k*2+2]);
            }
        }
 
        int query(int a,int b,int k,int l,int r){
            if(a<=l&&r<=b)return dat[k];
            if(r<=a||b<=l)return -INT_MAX;
            else {
                int vl=query(a,b,k*2+1,l,(l+r)/2);
                int vr=query(a,b,k*2+2,(l+r)/2,r);
                return max(vl,vr);
            }
        }
};
 
int sx,sy,ex,ey;
int N;
vector<P1> pos;
vector<P1> V;
Segment dp;
int flip_x=1,flip_y=1;
bool flip1,flip2,flip3;
 
void Flip(){
    if(sx>ex){
        if(sy<ey){
            sx=2*ex-sx;
            flip1=true;
        }
        else flip3=true;
    }
    if(sy>ey){
        if(sx<ex){
            sy=2*ey-sy;
            flip2=true;
        }
        else flip3=true;
    }
    if(flip3)sx*=-1,ex*=-1,sy*=-1,ey*=-1;
    //cout<<sx<<" "<<sy<<" "<<ex<<" "<<ey<<endl;
}
 
int LIS(){
    Segment dp;
    dp.init(N);
    for(int i=0;i<pos.size();++i){
        V.PB(P1(pos[i].second,-i));
    }
    sort(V.begin(),V.end());
    for(int i=0;i<V.size();++i){
        int j=-V[i].second;
        dp.update(j,1);
        dp.update(j,max(dat[j+dp.n-1],dp.query(0,j,0,0,dp.n)+1));
    }
    return dat[0];
}
 
double Distance(int p,int q){
    int s = abs(ex-sx)+abs(ey-sy);
    return (double)100*s-(20-5*PI)*p-(20-10*PI)*q;
}
 
signed main(){
    cin>>sx>>sy>>ex>>ey;
    cin>>N;
    Flip();
    for(int i=0;i<N;++i){
        int x,y;
        cin>>x>>y;
        if(flip1)x=2*ex-x;
        if(flip2)y=2*ey-y;
        if(flip3){ x*=-1,y*=-1; }
        if(sx<=x&&sy<=y&&ex>=x&&ey>=y)pos.PB(P1(x,y));
    }
    sort(pos.begin(),pos.end());
    int k=LIS();
    if(k==-INT_MAX)printf("%.11f\n",Distance(0,0));
    else if(k==min(abs(ex-sx),abs(ey-sy))+1)printf("%.11f\n",Distance(k-1,1));
    else printf("%.11f\n",Distance(k,0));
}

Measured memory_bytes: 16620
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,w,a,b,m=10000,dp[10001];
    cin>>n>>w;
    dp[0]=0;
    for(int i=1;i<=m;i++){
    	dp[i]=1e18;
    }
    for(int i=0;i<n;i++){
    	cin>>a>>b;
    	for(int j=m-a;j>=0;j--){
    		dp[j+a]=min(dp[j+a],dp[j]+b);
    	}
    }
    for(int i=m;i>=0;i--){
    	if(dp[i]<=w){
    		cout << i<<endl;
    		return 0;
    	}
    }
    
    return 0;
}



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

int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    pair<ll, ll> ans;
    if (a > k) {
        ans.first = a-k;
        ans.second = b;
    } else {
        ans.first = 0;
        ans.second = a+b-k;
        if (ans.second < 0) ans.second = 0;
    }
    cout << ans.first << " " << ans.second << endl;
    return 0;
}

Measured memory_bytes: 256
P = 10 ** 9 + 7
N = int(input())
X = [input()[::2] for i in range(N)]
Y = [-1] * (1<<N)

def calc(x, n):
    if Y[x] >= 0:
        return Y[x]
    if n < 0:
        return 1
    
    ret = 0
    for j in range(N):
        if x & (1<<j) and X[n][j] == "1":
            ret += calc(x-(1<<j), n-1)
            ret %= P
    Y[x] = ret
    return ret

print(calc((1<<N)-1, N-1))


Measured memory_bytes: 62428
#include<iostream>

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

using namespace std;

int abs(int n)
{
  if (n<0) n*=-1;
  return n;
}

int main()
{
    int n,x,y;
    cin >> n >> x >> y;

    int ans[n+1];
  	rep(i,1,n) ans[i]=0;
  
  	rep(i,1,n-1)
    {
      rep(j,i+1,n)
      {
        int min = j - i;
        int tmp = abs(x - i) + 1 + abs(y-j);
        int tmp2 = abs(y - i) + 1 + abs(j -x);
        if (tmp < min) min = tmp;
        if (tmp2 < min) min = tmp2;
        ans[min]++;
      }
    }
      
  
    rep(i,1,n-1)     cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X,string Y){
  int c[N+1][N+1];
  int m=X.size();
  int n=Y.size();
  int maxl=0;
  X=' '+X;
  Y=' '+Y;
  for(int i=0;i<=m;i++)c[i][0]=0;
  for(int j=1;j<=n;j++)c[0][j]=0;
  
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(X[i]==Y[j]){
	c[i][j]=c[i-1][j-1]+1;
      }else{
	c[i][j]=max(c[i-1][j],c[i][j-1]);
      }
      maxl=max(maxl,c[i][j]);
    }
  }
  return maxl;
}

int main() {
  string s1,s2;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s1 >> s2;
    cout << lcs(s1,s2) << endl;
  }
  return 0;
}



Measured memory_bytes: 7064
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.HashMap;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        abc164_c solver = new abc164_c();
        solver.solve(1, in, out);
        out.close();
    }

    static class abc164_c {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long N = in.nextLong();
            //String S[] = new String[2147483647];
//          String S[] = new String[9999999];
            int brakecount = 0;
            HashMap<String, Integer> S = new HashMap<String, Integer>();
            for (long i = 0; i < N; i++) {
                String inS = in.next();
                if (!S.containsKey(inS)) {
                    S.put(inS, 0);
                    brakecount++;
                }
            }
        /*
        Arrays.sort(S);
        String oldS = "";
        for (String item :S
             ) {
            if (oldS.isEmpty()) {
                oldS = item;
            }
            if(item.compareTo(oldS)!=0){
                brakecount++;
            }
        }
        */
            out.println(brakecount);
        }

    }
}



Measured memory_bytes: 77116
#include<bits/stdc++.h>
typedef long double ld;
using namespace std;
int main(void){
  int n,k; cin>>n>>k;
  vector<int> p(n);
  for(auto& i:p) cin>>i;
  int m=0,j=0,cnt=0;
  for(int i=0; i<=n-k; ++i){
    if(i==0) for(int j=0; j<k; ++j) cnt+=p[j];
    else cnt+=p[i+k-1]-p[i-1];
    if(cnt>m) m=cnt,j=i;
  }
  ld res=0;
  for(int i=j; i<j+k; ++i) res+=((ld)1/p[i])*(p[i]*(p[i]+1))*0.5;
  printf("%Lf",res);
  return 0;
}

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

int odd,even;

main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a;
		scanf("%d",&a);
		if(a%2==0)
			even++;
		else
			odd++;
	}
	if(odd%2==1)
	{
		if(even==0)
			printf("YES");
		else
			printf("NO");
	}
	else
		printf("YES");
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  cin >> N;

  if (N > 10 && N < 100)
    N -= N / 10 * 10;
  else if (N > 100) {
    N -= N / 100 * 100;
    N -= N / 10 * 10;
  }

  if (N == 2 || N == 4 || N == 5 || N == 7 || N == 9)
    cout << "hon" << endl;
  else if (N == 0 || N == 1 || N == 6 || N == 8)
    cout << "pon" << endl;
  else
    cout << "bon" << endl;

  return 0;
}

Measured memory_bytes: 3636
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in); 
		int N = input.nextInt();
		long W = input.nextLong();
		long[][] dp = new long[101][100001]; //Minimum weights to get value v by item N
		//100000 = 100*1000 = (max items)*(max value)
		//Arrays.fill(dp, (long)(1e5));
		//Don't need all rows (only 2 rows needed for comparison)
		long[] w = new long[N+1];
		int[] v = new int[N+1];
		int ans = 0;
		for (int i = 0; i <= 100; i++) {
			for (int j = 0; j <= 100000; j++) { //Arrays.fill = too much memory
				//Therefore implement yourself for optimization convenience
				dp[i][j]=(long)(1e9+1);
			} 
		}
		for (int i = 1; i <= N; i++) {
			w[i]=input.nextLong();
			v[i] = input.nextInt();
		}
		dp[1][v[1]]=w[1];
		if (w[1]<=W) ans=Math.max(ans, v[1]);
		for (int i = 2; i <= N; i++) {
			dp[i][v[i]]=w[i];
			for (int val = 1; val <= 100000; val++){
				dp[i][val]=Math.min(dp[i][val],dp[i-1][val]);
				if (val-v[i]>0) dp[i][val] = Math.min(dp[i][val], dp[i-1][val-v[i]]+w[i]);
				if (dp[i][val]<=W) ans=Math.max(ans, val);
			}
		} 
		System.out.println(ans);
	}	
}

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

using namespace std;

//static const long long MOD = 1000000007;

int main() {
    int H, W, answer = 0;

    // input
    cin >> H >> W;

    char S[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }

    // process
    int North[H][W], East[H][W], South[H][W], West[H][W];
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i >= 1 && S[i - 1][j] == '.') {
                North[i][j] = North[i - 1][j] + 1;
            } else {
                North[i][j] = 0;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = W - 1; j >= 0; j--) {
            if (j <= W - 2 && S[i][j + 1] == '.') {
                East[i][j] = East[i][j + 1] + 1;
            } else {
                East[i][j] = 0;
            }
        }
    }
    for (int i = H - 1; i >= 0; i--) {
        for (int j = 0; j < W; j++) {
            if (i <= H - 2 && S[i + 1][j] == '.') {
                South[i][j] = South[i + 1][j] + 1;
            } else {
                South[i][j] = 0;
            }
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (j >= 1 && S[i][j - 1] == '.') {
                West[i][j] = West[i][j - 1] + 1;
            } else {
                West[i][j] = 0;
            }
        }
    }

    int sum;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '.') {
                sum = North[i][j] + East[i][j] + South[i][j] + West[i][j];
                if (answer < sum) {
                    answer = sum;
                }
            }
        }
    }

    cout << answer + 1;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    fenwick_tree<ll> fw(N);
    rep(i, N) {
        int a;
        cin >> a;
        fw.add(i, a);
    }

    rep(i, Q) {
        int t, a, b;
        cin >> t >> a >> b;

        if (t == 0) {
            fw.add(a, b);
        }

        if (t == 1) {
            cout << fw.sum(a, b) << endl;
        }
    }
}

Measured memory_bytes: 8220
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
std::vector<int> v(3); int ans=9999;
int main(){
  cin >> v[0] >> v[1] >> v[2];
  for (size_t i = 0; i < 2; i++) {
    for (size_t l = i+1; l < 3; l++) {
      if(ans > v[i]+v[l]){
        ans = v[i]+v[l];
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = numeric_limits<int>::max() / 4;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

vvi adj(MAXN);
vi vis(MAXN);
void dfs(int u) {
  if (vis[u])
    return;
  vis[u] = true;
  for (int v : adj[u])
    dfs(v);
}

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    adj[u].eb(v);
    adj[v].eb(u);
  }

  int ans = -1;
  for (int i = 1; i <= n; ++i)
    if (!vis[i])
      dfs(i), ++ans;

  cout << ans << endl;
}

signed main() {
  // freopen(".in", "r", stdin);
  // freopen(".out", "w", stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 13668
#include<stdio.h>

int n,q,A[21],m;

int f(int i,int m){
	int x;
	if(m==0)return 1;
	if(i>=n)return 0;
	x=f(i+1,m) || f(i+1,m-A[i]);
	return x;
}
 
 int main(void){
 	int q,m;
 	scanf("%d",&n);
 	int i;
 	for(i=0;i<n;i++){
 		scanf("%d",&A[i]);
 	}
 	scanf("%d",&q);
 	for(i=0;i<q;i++){
 		scanf("%d",&m);
 		if(f(0,m)==1){
 			printf("yes\n");
 		}else{
 			printf("no\n");
 		}
 	}
 	return 0;
}


Measured memory_bytes: 2104
// Problem : E - Sequence Sum
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
#define pb push_back
#define mod 1000000007
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
} 
ll factorial[1000007];
void fact(ll n)
{
    memset(factorial,0,sizeof(factorial));
    factorial[0]=1;
factorial[1]=1;

    for(int i=1;i<n;i++)
    {
        factorial[i]=(factorial[i-1]*i)%mod;
    }
    
}
ll ncr(ll n,ll r)
{
    ll ans=1;
    ll i;
    ans=factorial[n];
    ll ans1=power(factorial[n-r],mod-2);
    ll ans2=power(factorial[r],mod-2);
    ans=((ans*ans1)%mod*ans2)%mod;
    return ans;
}
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

bool prime[100000006];
void sieve(ll n){
    memset(prime,true,sizeof(prime));
	prime[1]=false; 
    for (ll p=2;p*p<=n;p++){
        if (prime[p]){  
            for (ll i=p*p;i<=n;i+=p)
                prime[i]=false;
        }
    }
}
void bfs(vector<int> v[],int o,int n,int dp[]){
	queue<int> q;
	q.push(o);
	dp[o]=0;
	bool visited[n+1]={0};
	visited[o]=true;
	while(q.empty()==false){
		int a=q.front();
		q.pop();
		for(int i=0;i<v[a].size();i++){
			if(visited[v[a][i]]==false){
				visited[v[a][i]]=true;
				q.push(v[a][i]);
				dp[v[a][i]]=dp[a]+1;
			}
		}
	}
}
int nov[1000001];
bool visited[1000001];
int dp[1000001];
int dfs(vector<int> v[],int o)
{
    if(visited[o]==0)
    {
        visited[o]=1;
        for(int i=0;i<v[o].size();i++)
        {
            if(visited[v[o][i]]==0)
            {
            dp[v[o][i]]=dp[o]+1;
            nov[o]+=dfs(v,v[o][i]);
            }
        }
        return nov[o]+1;
    }
    else
    return 0;
}
// string s=bitset<64>(n).to_string();
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n,m,x;
	cin>>n>>x>>m;
	// cout<<n<<x<<m<<endl;
	map<ll,ll> mp;
	vector<ll> v;
	ll temp=x;
	ll sum=0;
	while(mp.find(temp%m)==mp.end())
	{
		temp=temp%m;
		mp[temp]=v.size();
		v.pb(temp);
		// cout<<temp<<" ";
		temp*=temp;
	}
	ll idx=mp[temp%m];
	// cout<<idx<<endl;
	// cout<<endl;
	// cout<<v.size()<<endl;
	if(n<=idx)
	{
		ll sum=0;
		for(int i=0;i<n;i++)
		{
			sum+=v[i];
		}
		cout<<sum<<endl;
	}
	else
	{
		ll sz=v.size()-idx;
		ll temp1=(n-idx)/sz;
		ll temp2=(n-idx)%sz;
		ll sum1=0;
		for(int i=idx;i<v.size();i++){
			sum1+=v[i];
		}
		ll res=sum1*temp1;
		for(int i=idx;i<idx+temp2;i++)
		{
			res+=v[i];
		}
		for(int i=0;i<idx;i++)
		{
			res+=v[i];
		}
		cout<<res<<endl;
	}
    
	return 0;
}


Measured memory_bytes: 6680
<?php
//error_reporting(0);
$N = (int)trim(fgets(STDIN));
//$R = trim(fgets(STDIN));
//list($A,$B,$C,$D) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$s = trim(fgets(STDIN));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

for($i=0;$i<$N;$i++) {
  $S = trim(fgets(STDIN));
  $k[$S]=1;
}
printf("%d\n",count($k));

Measured memory_bytes: 31948
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    vecl A(N); REP(i,N) cin >> A[i];
    ll kabu = 0;
    ll cur = 1000;
    REP(i,N-1) {
        if(A[i] < A[i+1]) {
            kabu += cur/A[i];
            cur %= A[i];
            cur += A[i+1]*kabu;
            kabu = 0;
        }
    }
    cout << cur << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin >> S >> T;
  int a=0,b;
  b=S.size();
  for(int i=0;i<b;i++){
   if(S.at(i)==T.at(i))
   {
   }
    else{
    a=1;
    }
  }
  if(a==0){
   cout << "Yes" << endl;
  }
  else{
   cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 3628
main = interact $ unlines.map (show.reversePolish) . lines

reversePolish :: String -> Double
reversePolish = solve [] .words

solve :: [Double] -> [String] -> Double
solve acc [] = head acc
solve acc (s:ss)
    | s `elem` ["+","-","*","/"] = solve (func (op s) acc) ss
    | otherwise = solve (read s:acc) ss

func :: Num a => (a -> a -> a) -> [a] -> [a]
func f (x:y:as) = f y x : as

op :: (Num a , Fractional a) => String -> (a -> a -> a)
op "+" = (+)
op "-" = (-)
op "*" = (*)
op "/" = (/)


Measured memory_bytes: 4292
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
  
  int A, B, C;
  
  scanf("%d%d%d", &A, &B, &C);
  
  if((A == 5 && B == 5 && C == 7) || (A == 7 && B == 5 && C == 5) || (A == 5 && B == 7 && C == 5))
    printf("YES");
  else
    printf("NO");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int A, B;
            cin >> A >> B;
                if(A == B){
                    cout << "Draw" << endl;
                        return 0;
                }else if(A == 1 || B == 2){
                    cout << "Alice" << endl;
                        return 0;
                }else if(A == 2 || B == 1){
                    cout << "Bob" << endl;
                        return 0;
                }else if(A > B){
                    cout << "Alice" << endl;
                }else if(A < B){
                    cout << "Bob" << endl;
                }
    return 0;}

Measured memory_bytes: 256
/**
*    created: 05.07.2020 20:54:47
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n;
    cin >> n;
    cout << (10000-n) % 1000 << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>

using namespace std;

long long gcd(long long a, long long b){
  if(b==0)return a;
  return gcd(b, a%b);
}

int main(){
  long long n, lgcd, a[100009];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  lgcd =a[0];
  for(int i=1;i<n;i++){
    lgcd = gcd(a[i], lgcd);
  }
  cout << lgcd << endl;
}

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



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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
	int n;
	scanf("%d", &n);
	vector<ll> v;
	int even = 0;
	int odd = 0;
	for (int i = 0; i < n; i++) {
		ll a;
		scanf("%lld", &a);
		if (a % 2 == 0) {
			even++;
		} else {
			odd++;
		}
	}
	string ans;
	if (odd % 2 == 1) {
		ans = "NO";
	} else {
		ans = "YES";
	}
	
	cout << ans << endl;

	
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    // Your code here!
    var s = readLine()!!.toMutableList()
    var cnt = 0
    var sr = s.reversed()
    
    for(i in 0..s.size-1){
        sr = s.reversed()
        if(s == sr){
            break
        }else{
            if(s[i] == sr[i]){
                continue
            }
            s[i] = sr[i]
            cnt += 1
        }
    }
    println(cnt)
}


Measured memory_bytes: 33648
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	int i;
	i = e- a;
	if (i <= k) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
	system("pause");
	return 0;
}


Measured memory_bytes: 504
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<long long>> VVLL;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

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

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

void debug(VI &arr){
	int n=arr.size();
	rep(i,n){
		cout<<arr.at(i)<<endl;
	}
}

void debug(VVI &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout << board.at(i).at(j) << " ";
		}
		cout<<endl;
	}
}

void debug(VVLL &board){
	int h = board.size();
	int w = board.at(0).size();
	rep(i,h){
		rep(j,w){
			cout<<board.at(i).at(j)<<" ";
		}
		cout<<endl;
	}
}

void debug(VS &board){
	int h = board.size();
	rep(i,h){
		cout<<board.at(i)<<endl;
	}
	return;
}

LL gcd(LL a,LL b){
	return b==0?a:gcd(b,a%b);
}

LL lcm(LL a,LL b){
	return a*b/gcd(a,b);
}

int main(){
	//cout<<fixed;
	//cout<<setprecision(9)<<...
	int k,n;
	cin>>k>>n;
	VI a(n);
	rep(i,n){
		cin>>a[i];
	}
	VI b(n);
	rep(i,n-1){
		b[i]=min(a[i+1]-a[i],k-(a[i+1]-a[i]));
	}
	b[n-1]=min(a[n-1]-a[0],k-(a[n-1]-a[0]));
	int M=-1;
	rep(i,n){
		chmax(M,b[i]);
	}
	cout<<k-M<<endl;
	return 0;
}


Measured memory_bytes: 1792
h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

sa = {}
for a,b in ab:
    for i in range(3):
        aa = a + i
        if aa < 3 or h < aa:
            continue
        for j in range(3):
            bb = b + j
            if bb < 3 or w < bb:
                continue
            id = "%d,%d" % (aa, bb)
            sa[id] = sa.get(id, 0) + 1

s = {}
for x in sa.values():
    s[x] = s.setdefault(x, 0) + 1
print((w - 2) * (h - 2) - len(sa.keys()))
for i in range(1, 10):
    print(s.get(i, 0))

Measured memory_bytes: 151176
MOD = 1000000007
h, w = map(int, input().split())
mp = [input() for _ in range(h)]
dp = [[0] * (w + 1) for _ in range(h + 1)]
dp[1][1] = 1
for y in range(1, h + 1):
  for x in range(1, w + 1):
    if mp[y - 1][x - 1] == "#":continue
    dp[y][x] += dp[y - 1][x] + dp[y][x - 1]
    dp[y][x] %= MOD
print(dp[h][w])

Measured memory_bytes: 51944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    cout << (n - 2) * 180 << endl;
    return 0;
}


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

int main() {
  string ch;
  getline(cin, ch);
  int i;
  for (i = 0; i < ch.length(); i++) {
    if ('a' <= ch.at(i) && ch.at(i) <= 'z') {
      ch.at(i) -= 'a' - 'A';
    }else if ('A' <= ch.at(i) && ch.at(i) <= 'Z') {
      ch.at(i) += 'a' - 'A';
    }
  }
  cout << ch << endl;
  
  return 0;
}



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

int main() {
    int a, b, c, x, y, ans = 0;
    cin >> a >> b >> c >> x >> y;
    if(a + b < 2 * c) {
        ans = a * x + b * y;
    } else {
        int temp = min(x, y);
        ans = 2 * c * temp;
        x -= temp;
        y -= temp;
        ans += ((a < 2 * c)? a : 2 * c) * x;
        ans += ((b < 2 * c)? b : 2 * c) * y;
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderBeginnerContest164
{
	class Program
	{
		static void Main(string[] args)
		{
			var count = ReadInt();
			var results = new List<string>(count);
			for(var i = 0; i < count; i++)
			{
				results.Add(ReadString());
			}

			Console.WriteLine(results.Distinct().Count());
		}

		public static int ReadInt()
			=> int.Parse(Console.ReadLine());

		public static int[] ReadIntArray()
			=> Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		public static long ReadLong()
			=> long.Parse(Console.ReadLine());

		public static long[] ReadLongArray()
			=> Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

		public static string ReadString()
			=> Console.ReadLine();

		public static string[] ReadStringArray()
			=> Console.ReadLine().Split();
	}
}


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


ll ceil(ll x, ll y) { return (x + (y-1)) / y; }

ll grundy(ll K, ll A) {
  if (A < K) return 0;
  ll m = ceil(A, K);
  if (A % K == 0) return m;
  ll x = ceil(A % K, m);
  return grundy(K, A - m * x);
}

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  ll acc = 0;
  for (ll i = 0; i < N; i++) {
    ll a, k; cin >> a >> k;
    acc ^= grundy(k, a);
  }
  cout << (acc ? "Takahashi" : "Aoki") << endl;
  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  ll a, b, h;
  cin >> a >> b >> h;

  cout << (a + b) * (h / 2) << endl;

  return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vll a(3);
  rep(i,3) cin>>a[i];
  vsort(a);
  ll ans=a[2]-a[1];
  a[0]+=ans;
  ans+=(a[2]-a[0])/2;
  if((a[2]-a[0])%2) ans+=2;
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static int[,] memo;
    static List<int> ar;
    static int[] nzw;
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        nzw = Input.ar;
        ar = new List<int>() { nzw[1], nzw[2] };
        ar.AddRange(Input.ar);
        memo = new int[nzw[0]+2, 2];
        for (var i = 0; i <= nzw[0]+1; i++)
            for (var k = 0; k < 2; k++)
                memo[i, k] = -1;
        WriteLine(dfs(1, 0));
    }
    static int dfs(int p,int t)
    {
        if (memo[p, t] != -1) return memo[p,t];
        var pri = (1 - 2 * ToInt32(t == 0)) * int.MaxValue;
        for(var i = p + 1; i <= nzw[0]+1; i++)
        {
            var s = 0;
            if (i == nzw[0] + 1)
                s = Abs(ar[p] - ar[i]);
            else s = dfs(i, 1 - t);
            if (t == 0)
                pri = Max(pri, s);
            else pri = Min(pri, s);
        }
        return memo[p, t] = pri;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N,K;
  cin >> N >> K;
  ll A[N];
  ll gcd = A[0];
  ll m = -1;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    m = max(A[i],m);
  }
  for (int i = 1; i < N; i++) {
    gcd = __gcd(gcd,A[i]);
  }
  //m - gcd * (n) = K に出来たらOK
  if (m >= K && (K - m) % gcd == 0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        int ans = 0;
        ArrayList<Integer> ansList = new ArrayList<Integer>();
        ArrayList<Integer> iList = new ArrayList<Integer>();
        
        Scanner scan = new Scanner(System.in);

        for(int i = 0; i < 5 ; i++) {
            int num = scan.nextInt();
            if (num % 10 == 0) {
                ansList.add(num);
            } else {
                iList.add(num);
            }
        }
        
        ArrayList<Integer> iOneList = new ArrayList<Integer>();
        ArrayList<Integer> iTenList = new ArrayList<Integer>();
        
        for(int iListData : iList) {
            iOneList.add(iListData % 10);
            ansList.add(iListData - (iListData % 10));
        }
        
        if (iOneList.size() != 0) {
            Collections.sort(iOneList);
    
            ansList.add(iOneList.get(0));
            for(int i = 1; i < iOneList.size(); i++) {
                ansList.add(iOneList.get(i) + (10 - iOneList.get(i)));
            }
        }
        
        for(int num : ansList) {
            ans = ans + num;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

ll gcd2(ll a, ll b) {
	if (a < b)swap(a, b);
	while (b) {
		a %= b;
		swap(a, b);
	}
	return a;
}

int main() {
	ll N, M; cin >> N >> M;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	ll ans = 0;
	ll sd = 0, p = 1, temp = a[0];
	while (temp % 2 == 0) { temp /= 2, sd++; }
	for (int i = 0; i < N ; i++) {
		ll cnt = 0, temp = a[i];
		while (temp % 2 == 0) {
			temp /= 2;
			cnt++;
		}

		if (sd != cnt) {
			p = M + 1;
			break;
		}
		p = p * (a[i] / 2) / gcd2(p, a[i] / 2);
		//cout << "gcd=" << gcd(p, a[i] / 2) << endl;
		//cout << "p=" << p << endl;
		
		
	}

	ans = (M / p + 1) / 2;
	cout << ans << endl;
}



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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

ll C(int n, int k)
{
    ll res = 1;
    for (int i = 0; i < k; i++) {
        res *= n - i;
        res /= i + 1;
    }
    return res;
}

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

    int n, a, b; cin >> n >> a >> b;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];

    sort(v.begin(), v.end(), greater<ll>());

    ll msum = 0; int mnum = 0; ll cnt = 0;
    for (int i = a; i <= b; i++) {
        ll total = accumulate(v.begin(), v.begin() + i, 0LL);
        if (total * mnum >= msum * i) {
            msum = total, mnum = i;
            ll tmp = C(
                count(v.begin(), v.end(), *(v.begin() + i - 1)),
                count(v.begin(), v.begin() + i, *(v.begin() + i - 1))
            );
            if (total * mnum == msum * i) cnt += tmp;
            else cnt = tmp;
        }
    }
    cout << fixed << setprecision(15) << (double)msum / mnum << endl; 
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
   int a,b;
   char op;

   while (1) {

      scanf("%d %c %d",&a,&op,&b);
      
     if (op=='?') {
        break;
     }
      switch(op) {
         case '+' :
            printf("%d\n",a+b);
            break;
         case '-' :
            printf("%d\n",a-b);
            break;
         case '/' :
            printf("%d\n",a/b);
            break;
         case '*' :
            printf("%d\n",a*b);
            break;
      }
   }

   return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a1 = sc.nextInt();
        int a2 = sc.nextInt();
        int a3 = sc.nextInt();
        if (a1 + a2 + a3 >= 22) {
            System.out.println("bust");
            return;
        }
        System.out.println("win");
    }

}


Measured memory_bytes: 23764