akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int a; string s; cin >> a >> s;
  cout << (a >= 3200 ? s : "red") << '\n';
  return 0;
}


Measured memory_bytes: 256
def readinput():
    a,b,c,k = list(map(int,input().split()))
    return a,b,c,k

def main(a,b,c,k):
    if(a>=k):
        return k
    k2=k-a
    if(b>=k2):
        return a
    k3=k2-b
    return a-k3
    

if __name__=='__main__':
    a,b,c,k=readinput()
    ans=main(a,b,c,k)
    print(ans)


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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  rep(i, n) {
    a[i].first = i + 1;
    cin >> a[i].second;
  }

  sort(a.begin(), a.end(), 
       [](const pair<int, int>& a, const pair<int, int>& b) {
         return a.second < b.second;
       });

  rep(i, n) {
    cout << a[i].first << (i == n-1 ? "\n" : " ");
  }
  return 0;
}


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

using namespace std;
typedef map<string, int> simap;        

int main() {
    int n, m;
    simap assoc;
    cin >> n;
    for(int i=0; i<n; i++) {
        string s;
        cin >> s;
        assoc[s]++;
    }
    cin >> m;
    for(int i=0; i<m; i++) {
        string t;
        cin >> t;
        assoc[t]--;
    }
    int r = 0;
    for(simap::iterator itr=assoc.begin(); itr!=assoc.end(); ++itr) {
        r = max(r, itr->second);
    }
    cout << r << endl;
}

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

using namespace std;

typedef pair<double,double> pdd;
const double eps = 1e-7;

bool eq(double a,double b)
{
    return abs(a-b)<eps;
}

vector<double> solve(double a,double b,double c)
{
    vector<double> ans;
    double d = b*b - 4*a*c;

    if(eq(d,0))
    {
        ans.push_back(-b/2/a);
        ans.push_back(-b/2/a);
    }else if(d>eps)
    {
        d = sqrt(d);
        ans.push_back((-b+d)/(2*a));
        ans.push_back((-b-d)/(2*a));
    }
    return ans;
}

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

    int x,y,r;
    cin>>x>>y>>r;

    int q;
    cin>>q;

    cout<<fixed<<setprecision(10);
    while(q--)
    {
        double x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;

        double a,b,b1,c,k;
        vector<double> ans;
        vector<pdd> rs;
        if(eq(x1,x2))
        {
            a = 1;
            b = -2*y;
            c = y*y - r*r + (x1-x)*(x1-x);
            ans = solve(a,b,c);
            for(int i=0;i<ans.size();i++)
            {
                rs.push_back(pdd(x1,ans[i]));
            }
        }else
        {
            k = (y2-y1)/(x2-x1);
            b1 = y1 - k*x1;
            a = 1 + k*k;
            c = x*x + (b1-y)*(b1-y) - r*r;
            b = 2*k*(b1-y)-2*x;
            ans  = solve(a,b,c);

            for(int i=0;i<ans.size();i++)
            {
                rs.push_back(pdd(ans[i],k*ans[i]+b1));
            }

        }

        sort(rs.begin(),rs.end());
        for(int i=0;i<rs.size();i++)
        {
            cout<<rs[i].first<<" "<<rs[i].second<<" ";
        }
        cout<<endl;
    }

    return 0;
}



Measured memory_bytes: 3312
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
  cin>>n;
  vec1(a,n);
  vector<int> r(n,0);
  queue<int> q;
	for(int i=n;i>0;i--){
    	if(i>n/2){r[i-1]=a[i-1];continue;}
      int cnt =0;
     	for(int j=2;j*i<=n;j++){
           cnt +=r[j*i-1];
        }
      if(a[i-1]!=(cnt%2)) r[i-1]=1;
    }
  int cnt =0;
  rep(i,n) if(r[i]) {cnt ++;q.push(i+1);}
  cout<<cnt <<endl;
  while(q.size()){
  	cout<<q.front()<<" ";
    q.pop();
  }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
int main()
{
    string s;
    cin >> s;
    if (s[1] == 'R')
    {
        cout << "ABC";
    }
    else
    {
        cout << "ARC";
    }
}


Measured memory_bytes: 3624
#                         author:  kagemeka 
#                         created: 2019-11-08 13:38:56(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n = sys.stdin.readline().rstrip()
    s = sum([int(d) for d in n])
    print('Yes' if int(n) % s == 0 else 'No')


if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 2940
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include<bits/stdc++.h>
 
using namespace std;
#define ll long long 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0); 
#define nl "\n"
#define sz(a) (int)(a).size() 
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;  
#define mt make_tuple 
#define vec vector
 
#define int long long 
 
const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;
 
typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;
 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
 
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve(int test) {
	
	string s,t; cin >> s >>  t;

	int ans = INF ; 

	for(int i = 0 ; i <= sz(s) - sz(t) ; ++i) {
		int cnt = 0 ; 
		for(int j = i ; j < i + sz(t) ; ++j) {
			if(s[j] != t[j-i]) ++cnt ; 
		}
		ans =min(ans, cnt) ;
	}
	cout << ans ; 
}

int32_t main() {
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif   

    fast;
	int t=1;
	// cin>>t;
	rep(i,1,t+1) {
		solve(i) ;
	}
 
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);    
#define f(i,j,k)  for(int i=j;i<k;i++)
#define fr(i,j,k) for(int i<=k-1;i>=j;i--)
#define ll long long
#define ld long double

using namespace std;

int main()
{
	fio
	int TC;
	TC=1;
	while(TC--)
	{
		ll n,k;
		int d = 0;
		cin>>n>>k;
		while(n!=0)
		{
			n=n/k;
			d++;
		}
		cout<<d<<endl;
		

	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
#define INF 1000000000000
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<lli,lli> P;

struct edge{ int u, v; lli cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
	vector< vector<lli> > distance_matrix;
};

template <typename T>
vector<int> argsort(const vector<T> &v) {

  // initialize original index locations
  vector<int> idx(v.size());
  iota(idx.begin(), idx.end(), 0);

  // sort indexes based on comparing values in v
  sort(idx.begin(), idx.end(),
       [&v](int i1, int i2) {return v[i1] < v[i2];});

  return idx;
}

template<typename T>
void displayVector(vector<T> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}



int main(){
	int N; cin >> N; 
	vector<lli> a(N), b(N,0), sum(N,0);
	REP(i,N){ cin >> a[i]; }

	for(int iter=N;0<iter;iter--){
		if(a[iter-1] != sum[iter-1]%2 ){ 
			for (lli i = 1; i * i <= iter; i++) {
        if (iter % i == 0) {
            sum[i-1]+=1;
            if (i * i != iter) sum[iter/i-1] += 1;
        }
			}
			b[iter-1] = 1;
    }
	}
	cout << accumulate(b.begin(), b.end(), 0) << endl;
	REP(i,N){
		if(b[i]){ cout << i+1 << endl; }
	}
	return 0;
}

Measured memory_bytes: 7924
while True:
    h, w = map(int, input().split())
    if h + w == 0:
        break
    for i in range(h):
        strict = ''
        for j in range(w):
            if i % 2 == 0:
                if j % 2 == 0:
                    strict += '#'
                else:
                    strict += '.'
            else:
                if j % 2 == 0:
                    strict += '.'
                else:
                    strict += '#'
        print(strict)
    print()


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int n,a,b;
  cin>>n;
  a=n/100;
  b=n%100;
  if(1<=a && a<=12 && 1<=b && b<=12){
    cout<<"AMBIGUOUS"<<endl;
    return 0;
  }else if((a==0 || a>12) && 1<=b && b<=12){
    cout<<"YYMM"<<endl;
    return 0;
  }else if(1<=a && a<=12 && (b==0 || b>12)){
    cout<<"MMYY"<<endl;
    return 0;
  }else{
    cout<<"NA"<<endl;
    return 0;
  }
  
  
  
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){
  int p,n;
  cin >> p >> n;
  int m=n*2;
  map<pair<int,int>,int> mp;
  rep(i,p){
    int x,y; char c;
    cin >> x >> y >> c;
    if(c=='W'){ y+=n;}
    x %= m;
    y %= m;
    mp[{x,y}]++;
  }
  
  vector<vector<int>> imos(3*m, vector<int>(3*m,0));
  for(auto it:mp){
    int x=it.F.F;
    int y=it.F.S;
    int c=it.S;
//cout<<x<<" "<<y<<" "<<c<<endl;    
    imos[x][y] += c;
    imos[x+n][y] += -c;
    imos[x][y+n] += -c;
    imos[x+n][y+n] += c;
    
    x=it.F.F+m; y=it.F.S;
    imos[x][y] += c;
    imos[x+n][y] += -c;
    imos[x][y+n] += -c;
    imos[x+n][y+n] += c;

    x=it.F.F; y=it.F.S+m;
    imos[x][y] += c;
    imos[x+n][y] += -c;
    imos[x][y+n] += -c;
    imos[x+n][y+n] += c;
    
    x=it.F.F+m; y=it.F.S+m;
    imos[x][y] += c;
    imos[x+n][y] += -c;
    imos[x][y+n] += -c;
    imos[x+n][y+n] += c;

  }
  rep(i,2*m)rep(j,2*m){ imos[i+1][j]+=imos[i][j]; }
  rep(j,2*m)rep(i,2*m){ imos[i][j+1]+=imos[i][j]; }                   
  
  int ans=-1;
  for(int i=n; i<m+n; i++)for(int j=n; j<m+n; j++){ ans = max(ans,imos[i][j]+imos[i+n][j+n]);}
/*
  rep(i,m){ rep(j,m){ 
    ans = max(ans,imos[i][j]);
    cout <<imos[i][j]<<" ";
  }cout<<endl;}
*/ 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 147328
#include <stdio.h>
#include <math.h>
int main(void) {

	
	int A, B, C;
	scanf("%d%d%d",&A, &B, &C);

	if (A - B >= C) {
		printf("%d",0);
	}
	else if (A - B < C) {
		printf("%d", C - A + B);
	}


	return 0;

}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int n;
  cin >> n;
  double bunbo = 0.0;
  rep(i, n) {
    double tmp;
    cin >> tmp;
    bunbo += 1.0 / tmp;
  }
  cout << setprecision(12) << 1.0 / bunbo;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; cin >> N; 
	pair<string, int> S[110]; 
	int P[110] = {}; 
	for(int i = 0; i < N; i++){
		cin >> S[i].first >> S[i].second; 
		P[i] = S[i].second; 
		S[i].second *= -1; 
	}
	sort(S, S+N); 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(S[i].second + P[j] == 0){
				cout << j+1 << endl; 
			}
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                         
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a.at(i);
  }
  int max=0;
  for(int i=0; i<N; i++){
    if(max<=a.at(i)){
      max=a.at(i);
    }
  }
  int min=1001;
  for(int i=0; i<N; i++){
    if(min>=a.at(i)){
      min=a.at(i);
    }
  }
  cout << max-min << endl;
}

Measured memory_bytes: 256
import numpy as np
from itertools import combinations


h, w, k = map(int, input().split())
C = np.array([list(input()) for j in range(h)]) == "#"
out = 0

for row_n in range(h):
    for row_select in combinations(C, r=row_n + 1):
        # print(list(zip(*row_select)))
        for col_n in range(w):
            for col_select in combinations(zip(*row_select), r=col_n + 1):
                if np.array(col_select).sum() == k:
                    out += 1
print(out)


Measured memory_bytes: 27288
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <climits>
using namespace std;

long long int get_sum(int b, vector<int> A, int N);

int main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for(int i=0; i<N; ++i){
    cin >> A[i];
    B[i] = A[i] - (i+1);
  }
  sort(B.begin(), B.end());
  size_t median_index = B.size() / 2;
  int median = (B.size() % 2 == 0
    ? static_cast<int>(B[median_index] + B[median_index - 1]) / 2
    : B[median_index]);
  cout << get_sum(median, A, N) << endl;

  return 0;
}

long long int get_sum(int b, vector<int> A, int N){
  long long int sum = 0;
  for(int i=0; i < N; i++){
    sum += abs(A[i]-(b+i+1));
  }
  return sum;
}


Measured memory_bytes: 2560
#include<iostream>
int main(){
  while(1){
    int n,m,tmp=0;
    int max=-1;
    int A[1000]={0};
    std::cin>>n>>m;
    for(int i=0;i<n;i++){
      std::cin>>A[i];
    }
    if(A[0]==0&&A[1]==0){
      break;
    }
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	tmp=A[i]+A[j];
	if(tmp>max&&tmp<=m){
	  max=tmp;
	}
      }
    }
    if(max>0){
      std::cout<<max<<"\n";
    }else{
      std::cout<<"NONE\n";
    }
  }
  return 0;
}



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

int main() {
int N,K;
  cin >>N;
  cin >>K;
vector<int> P(N);
  for(int i=0;i<K;i++){
  int d;
  cin >> d;
  for(int j=0;j<d;j++){
  int A;
	cin >>A;
    for(int k=0;k<N;k++){
      if(A==k+1){
        P.at(k)++;
      }
    }
  }
  }
  int Ans;
  for(int i=0;i<N;i++){
    if(P.at(i)==0){
      Ans++;
    }
  }
  cout <<Ans<<endl;
}
  

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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;

//ここから書き始める
int main()
{
	cout << setprecision(10);
	int N ; cin >> N;
	vector<vector<ll>> a(N,vector<ll>(3));
	rep(i,N){
		rep(k,3){
			cin >> a[i][k];
		}
	}
	vector<vector<ll>> dp(101000,vector<ll> (3));
	rep(i,101000){
		rep(j,3){
			dp[i][j] = 0;
		}
	}
	rep(i,N){
		rep(j,3){
			rep(k,3){
				if(j!=k){
					chmax(dp[i+1][j],dp[i][k]+a[i][j]);
				}
			}
		}
	}
	ll ans = 0;
	rep(i,3){
		chmax(ans,dp[N][i]);
	}
	cout << ans << endl;

}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 (a>b) { a=b; return 1; } return 0; }

ll beki(ll a, ll n){
    if(n == 0){
        return 1;
    }
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

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

    ll N,P; cin >> N >> P;

    if(N == 1) {cout << P << endl; return 0;}
    if(N >= 41) {cout << 1 << endl; return 0;}
    if(P == 1) {cout << 1 << endl; return 0;}

    ll ans = 1;
    for(ll i = 1; beki(i,N) <= P; i++){
        ll c = beki(i,N);
        if(P % c == 0) ans = i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <sstream>
#include <math.h>
#include <functional>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define SORT(c) sort((c).begin(),(c).end())
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define WARU 1000000007

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

vector<int> max_sub(string S) {
	vector<int> A(S.size());
	A[0] = S.size();
	int i = 1, j = 0;
	while (i < S.size()) {
		while (i + j < S.size() && S[j] == S[i + j]) ++j;
		A[i] = j;
		if (j == 0) { ++i; continue; }
		int k = 1;
		while (i + k < S.size() && k + A[k] < j) A[i + k] = A[k], ++k;
		i += k; j -= k;
	}
	return A;
}

int main() {
	int a; cin >> a;
	string S;
	cin >> S;
	int res = 0;
	rep(i, S.size()) {
		auto lcp = max_sub(S.substr(i, S.size() - i));
	
		for (int j = 0; j < lcp.size(); j++) {
			int l = min(lcp[j], j);
			res = max(res, l);
		}
	}
	cout << res << endl;


}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
	string w, s;
	int cnt = 0;

	cin >> w;
	for (unsigned int i = 0; i < w.length(); i++){
		if (isupper(w[i])) w[i] = tolower(w[i]);
	}

	while (1){
		cin >> s;
		if (s == "END_OF_TEXT") break;
		
		if (s.length() > w.length() + 1) continue;
		for (unsigned int i = 0; i < s.length(); i++) {
			if (s[i] == '.' && i == s.length() - 1) s.erase(i);
			if (isupper(s[i])) s[i] = tolower(s[i]);
		}

		if (s == w) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1192
from collections import Counter
N,K = map(int,input().split())
src = [tuple(map(int,input().split())) for i in range(N)]
src.sort(key=lambda x:-x[1])

selected = Counter()
ans = 0
stack = []

for t,d in src[:K]:
    ans += d
    selected[t] += 1
    stack.append((t,d))
ans += len(selected)**2

tmp = ans
for t,d in src[K:]:
    if t in selected: continue
    while stack:
        t0,d0 = stack.pop()
        if selected[t0] > 1:
            tmp += d - d0 + 2*len(selected)+1
            ans = max(ans, tmp)
            selected[t0] -= 1
            selected[t] += 1
            break
    else:
        break
print(ans)

Measured memory_bytes: 28088
N = int(input())

t = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    s = str(i)
    t[int(s[0])][int(s[-1])] += 1

result = 0
for i in range(1, 10):
    for j in range(1, 10):
        result += t[i][j] * t[j][i]
print(result)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  string A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  string C[n];
  for(int i=0;i<n;i++) C[i]=A[i];
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=n-1;j>i;j--){
      if(C[j][1]<C[j-1][1]){
	swap(C[j],C[j-1]);
      }
    }
  }
  string x[10],y[10];
  for(int i=0;i<n;i++){
    x[A[i][1]-'0']+=A[i][0];
    y[C[i][1]-'0']+=C[i][0];
  }
  ans=1;
  for(int i=0;i<10;i++) ans&=x[i]==y[i]; 
  for(int i=0;i<n;i++) cout<<C[i]<<" \n"[i==n-1];
  cout<<(ans?"Stable":"Not stable")<<endl;
  
  for(int i=0;i<n;i++) C[i]=A[i];
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(C[j][1]<C[minj][1]){
	minj=j;
      }
    }
    if(i!=minj) swap(C[i],C[minj]);
  }
  
  for(int i=0;i<10;i++) x[i]=y[i]="";
  for(int i=0;i<n;i++){
    x[A[i][1]-'0']+=A[i][0];
    y[C[i][1]-'0']+=C[i][0];
  }
  ans=1;
  for(int i=0;i<10;i++) ans&=x[i]==y[i]; 
  for(int i=0;i<n;i++) cout<<C[i]<<" \n"[i==n-1];
  cout<<(ans?"Stable":"Not stable")<<endl;
  
  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll N, ans = 0;
  std::cin >> N;
  std::vector<string> S(N);
  for(int i=0;i<N;i++) std::cin >> S[i];
  for(int i=0;i<N;i++) sort(S[i].begin(), S[i].end());
  sort(S.begin(), S.end());
  ll count=0;
  string now;
  for(int i=0;i<N;i++){
    if(i==0||now!=S[i]){
      ans += ((count-1)*count)/2;
      now = S[i];
      count = 1;
    }else count++;
    if(i==N-1) ans += ((count-1)*count)/2;
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2560
function main(input) {
input=input.split("\n");
var a=input[0].split(" ").map((n)=>parseInt(n,10));
var b=parseInt(input[1],10);
  
var max=Math.max(a[0],a[1],a[2]);
var c=Math.pow(2,b);
var result=((a[0]+a[1]+a[2])+(max*c)-max);
  console.log(result);
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        int out = 0;
        for(int i = 0; i < s.length(); i++){
            if(s.charAt(i) == '1') out++;
        }
        System.out.println(out);
    }

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


Measured memory_bytes: 35704
#include <cstdio>
using namespace std;

int cnt[5];

int main(){
  for(int i = 1; i <= 6; i++){
    int x; scanf("%d", &x); cnt[x]++;
  }

  bool f = false;
  for(int i = 1; i <= 4; i++) if(cnt[i] == 3) f = true;

  puts(f ? "NO" : "YES");
  return 0;
}

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

int main(){
int N,M;
  cin >> N >> M;
   
vector<int> A(N);
  int sum=0;
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
  sum+=A[i];
}

sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  if(sum%(4*M)!=0){
  if(sum/(4*M)+0.5>A[M-1]){
  cout << "No" << endl;  
  }
  else {
    cout << "Yes" << endl;  
  }
  }
  
  else{
    if(sum/(4*M)>A[M-1]){
  cout << "No" << endl;  
  }
  else {
    cout << "Yes" << endl;  
  }
  }
  
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include <numeric>
#include<cmath>
#include<string>
using namespace std;
#define ll long long
typedef pair<ll,ll> p;
int main(void){
    int n;
    cin >> n;
    // cout << n<< endl;
    std::vector<int> d(n);
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    int a,b;
    a = d[(n/2)-1];
    b = d[(n/2)];
    
    cout << b-a <<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
main()
{
    long long N,h,n,t1,t2;int s=0;
    scanf("%lld",&N);
    for(h=1;h<=3500;h++)
    {
        for(n=1;n<=3500;n++)
        {
            t1=N*h*n;
            t2=4*h*n-N*n-N*h;
            if(t2>0&&t1%t2==0)
            {
                printf("%lld %lld %lld\n",h,n,t1/t2);
                s=1;break;
            }
        }
        if(s)break;
    }
}


Measured memory_bytes: 128
// #include <bits/stdc++.h>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cassert>
#include <cstring>
#include <cstdarg>
#include <cstdio>
#include <random>
#include <cmath>
#include <ctime>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
#include <bitset>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <array>
#include <list>
#include <map>
#include <set>

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)a.size()
 
typedef long long LL;
typedef pair<double, double> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<LL, LL> PLL;
 
const int INF = 1000 * 1000 * 1000;
const LL LINF = 1LL * INF * INF;
const long double PI = acos(-1.);
const double EPS = 1e-6;
LL mod = INF + 7;

const int maxn = 100010;

int main()
{
//  freopen("input.txt","r",stdin);
    LL s;
    cin >> s;
    cout << "0 0 ";
    LL x2,y3;
    x2 = INF;
    y3 = (s+INF-1)/INF;
    LL x3 = 1;
    LL y2 = x2*y3-s;
    // x2*y3 - y2*x3 = S;
    cout << x2 << " " << y2 << " ";
    cout << x3 << " " << y3 << " ";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#define _USE_MATH_DEFINES // M_PI????????????????????????
#include<math.h>
#pragma warning(disable:4996)
using namespace std;

static const int N=100;

int main(){
	int M[N][N]; // ?????????????????£??\??????
	int n, u, k, v;
	cin >> n;

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++) M[i][j]=0;
	}

	for(int i=0; i<n; i++){
		cin >> u >> k;
		u--; // ?????????????????????
		for(int j=0; j<k; j++){
			cin >> v;
			v--; // ?????????????????????
			M[u][v] = 1; // u??¨v?????????????????????
		}
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			if(j) cout << " ";
			cout << M[i][j];
		}
		cout << "\n";
	}
	return 0;
}

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

int N[4];
int num[10];

int main() {
	cin >> N[0] >> N[1] >> N[2] >> N[3];

	for( int i = 0; i < 4; i++ ) {
		if( N[i] == 1 || N[i] == 9 || N[i] == 7 || N[i] == 4 ) {
			num[N[i]]++;
		}
	}
	int ans = 0;
	if( num[1] && num[9] && num [7] && num[4] ) {
		ans = 1;
	}

	if( ans ) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pp;
double PI=acos(-1);
int const N = 5e5 + 10,M=5e6+10, oo = 1e9;
const int mod = oo+7;
const ll  OO = 3e18;

pair<ll,ll > prf[N],suff[N];
ll cum[N];
int n,aa[N];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>aa[i],cum[i]+=cum[i-1]+aa[i];
    prf[2]={aa[1],aa[2]};
    for(int i=3;i<n-1;i++){
        ll lee=cum[i]/2;
        int y=lower_bound(cum+1,cum+n+1,lee)-cum;
        ll f1=cum[i]-cum[y],f2=cum[y];
        ll f3=cum[i]-cum[y-1],f4=cum[y-1];
        if(abs(f1-f2)<abs(f3-f4))prf[i]={f1,f2};
        else prf[i]={f3,f4};
    }
    suff[n-1]={aa[n],aa[n-1]};
    for(int i=n-2;i>2;i--){
        ll lee=(cum[n]-cum[i-1])/2;
        int y=lower_bound(cum+1,cum+n+1,cum[i-1]+lee)-cum;
        ll f1=cum[y]-cum[i-1],f2=cum[n]-cum[y];
        ll f3=cum[y-1]-cum[i-1],f4=cum[n]-cum[y-1];
        if(abs(f1-f2)<abs(f3-f4))suff[i]={f1,f2};
        else suff[i]={f3,f4};
//        cout<<i<<' '<<suff[i].first<<' '<<suff[i].second<<endl;
    }
    ll an=OO;
    for(int i=2;i<=n-2;i++){
        ll mn=min(prf[i].first,prf[i].second);
        mn=min(mn,min(suff[i+1].first,suff[i+1].second));
        ll mx=max(prf[i].first,prf[i].second);
        mx=max(mx,max(suff[i+1].first,suff[i+1].second));
        if(mx-mn<an){
            an=mx-mn;
        }
    }
    cout<<an<<endl;
    return 0;
}


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

int main(){
	int n, ans;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	rep(i,n) {
		if (a[i] % 2 != 0) continue;
		while (!(a[i] % 2)) {
			ans++;
			a[i] /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int N, i;
    string cache;
    vector<string> W(100);
    bool flag = false;
    cin >> N;
    for(i = 0; i < N; ++i) {
        cin >> cache;
        auto result = find(W.begin(), W.end(), cache);
        if(result != W.end())
            flag = true;
        W[i] = cache;
        if(i != 0)
            if(W[i].front() != W[i-1].back())
                flag = true;

    }

    if(!flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		
		if (((r*100)+(g*10)+b)%4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		sc.close();
	}
}


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

int dist(int a, int b, int c, int d){
  return max( a - b, c - d);
}

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

  vector< int > xx(N), yy(N);
  for(int i = 0; i < N; i++){
    int a, b;
    scanf("%d %d", &a, &b);
    xx[i] = a + b;
    yy[i] = a - b;
  }

  int xxmax = *max_element(xx.begin(), xx.end());
  int xxmin = *min_element(xx.begin(), xx.end());
  int yymax = *max_element(yy.begin(), yy.end());
  int yymin = *min_element(yy.begin(), yy.end());

  int ret[2] = {};

  for(int i = 0; i < N; i++){
    ret[0] = max( ret[0], min( dist( xxmax, xx[i], yymax, yy[i]), dist( xx[i], xxmin, yy[i], yymin)));
    ret[1] = max( ret[1], min( dist( xxmax, xx[i], yy[i], yymin), dist( xx[i], xxmin, yymax, yy[i])));
  }
  cout << min( ret[0], ret[1]) << endl;
}

Measured memory_bytes: 1796
from bisect import bisect_left as bl

N = int(input())
L = list(map(int,input().split()))
L = sorted(L)

p = L[-1]
q = bl(L,p/2)
if N == 2 :
    r = L[0]
else :
    if abs((p/2)-L[q]) < abs((p/2)-L[q-1]) :
        r = L[q]
    else :
        r = L[q-1]
print(p,r)


Measured memory_bytes: 14428
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
 
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
 
int main(void){
    int n,k,i,r=1;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++){r=min(r*2,r+k);}
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>s;
  stack<char> st;
  for(int i=0;i<s.length();i++){
    if(st.size()<2){
      st.push(s[i]);
    }else{
      char a=st.top();st.pop();
      char b=st.top();st.pop();
      if(a=='T' && b=='S'){
        st.push(s[i]);
      }else{
        st.push(b);
        st.push(a);
        st.push(s[i]);
      }
    }
  }
  char a=st.top();st.pop();
  char b=st.top();st.pop();
  if(a=='T' && b=='S'){
    cout<<st.size()<<endl;
  }else cout<<st.size()+2<<endl;
  return 0;
}


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

int main() {
  char a;cin>>a;
  if(isupper(a))cout<<'A'<<endl;
  else cout<<'a'<<endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
using namespace std;

int main(void){
    int n;
    string s;
    cin>>s;
    n=s.size();
    vector <int>ans(n);
    rep(ri, 2){
        int cnt=0;
        rep(i,n){
            if (s[i]=='R'){
            cnt++;
            }
        else{
            ans[i]+=cnt/2;
            ans[i-1]+=(cnt+1)/2;
            cnt=0;
            }
        }
        reverse(ans.begin(), ans.end());
        reverse(s.begin(), s.end());

        rep(i, n){
            if (s[i]=='L'){
                s[i]='R';
            }
            else{
                s[i]='L';
            }
        }
        
        
    }
    rep(i, n){
        cout<<ans[i]<<endl;
    }
    cout<<endl;
    return 0;
}

    

Measured memory_bytes: 1088
#include<bits/stdc++.h>
using namespace std;
const int dr[]={-1,-1,-1,0,0,1,1,1};
const int dc[]={-1,0,1,-1,1,-1,0,1};
int h,w;
char m[55][55];
int count(int x,int y){
	int sum=0,r,c;
	for(int i=0;i<8;i++){
		r=x+dr[i];
		c=y+dc[i];
		if(r>=0&&r<h&&c>=0&&c<w&&m[r][c]=='#') sum++;
	}
	return sum;
}
int main(){
	cin>>h>>w;
	for(int i=0;i<h;i++) cin>>m[i];
	for(int i=0;i<h;i++) {
		for(int j=0;j<w;j++)
			if(m[i][j]=='.') m[i][j]='0'+count(i,j);
	}
	for(int i=0;i<h;i++) cout<<m[i]<<endl;
	return 0;
}


Measured memory_bytes: 256
import numpy as np
 
N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = np.maximum(dp[n-1][w:W+1], dp[n-1][:W+1-w]+v )

print(dp[N][W])

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

 using namespace std;

 int main() {
 int N, D; cin >> N >> D;
 vector<vector<int> > X(N, vector<int>(D));
 for (int i = 0; i < N; ++i) {
 for (int j = 0; j < D; ++j) {
 cin >> X[i][j];
 }
 }
 int ans = 0;
 for (int i = 0; i < N; ++i) {
for (int j = i+1; j < N; ++j) { int norm = 0;
for (int k = 0; k < D; ++k) {
 int diff = abs(X[i][k] - X[j][k]);
norm += diff * diff; }
 // check whether norm = k for some k
 bool flag = false;
 for (int k = 0; k <= norm; ++k) {
 if (k * k == norm) {
 flag = true;
 }
 }
 if (flag) ++ans;
 }
 }
cout << ans << endl;
 }


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

#define col first
#define cn second

typedef pair<int, int> PR;

pair<int, int> puyo[10000+10] , tmp;

int sum;


int chek(int , /*PR[10000 + 10],*/ int ,int,int);


int main()
{
	int n;
	int pn=0;

	int a;

	int i;

	int sa=0;

	while (cin >> n, n != 0)
	{
		sa = 0;
		sum = n;
		pn = 0;

		cin >> a;
		puyo[pn].col = a;
		puyo[pn].cn = 1;


		for (i = 1; i < n; i++)
		{
			cin >> a;

			if (puyo[pn].col == a)
			{
				puyo[pn].cn++;
			}
			else
			{
				pn++;
				puyo[pn].col = a;
				puyo[pn].cn = 1;
			}
		}

		pn++;

		for (i = 1; i < pn - 1; i++)
		{

			if (puyo[i].cn == 3)
			{
				if (puyo[i + 1].col == puyo[i - 1].col && puyo[i + 1].cn + puyo[i - 1].cn >= 5)
				{
					//tmp = puyo[i + 1];
					//puyo[i + 1].cn--;

					sa = 3 + puyo[i + 1].cn + puyo[i - 1].cn;

					sum = min(sum, n - chek(pn, i - 2, i + 2, sa));
					//puyo[i + 1] = tmp;
				}
			}

			if( puyo[i+1].cn==1 && puyo[i].col == puyo[i+2].col )
			{
				if (puyo[i].cn + puyo[i + 2].cn >= 3)
				{
					//puyo[i + 1].cn--;
					sa = 1 + puyo[i].cn + puyo[i + 2].cn;

					sum = min(sum, n - chek(pn, i - 1, i + 3, sa));
					
				}
			}

			if (puyo[i - 1].cn == 1 && puyo[i].col == puyo[i - 2].col)
			{
				if (puyo[i].cn + puyo[i - 2].cn >= 3)
				{
					//puyo[i - 1].cn--;
					sa = 1 + puyo[i].cn + puyo[i - 2].cn;

					sum = min(sum, n - chek(pn, i - 3, i + 1, sa));
				}
			}
		}
		cout << sum << endl;
	}
	return 0;
}


int chek(int pn/*, PR tp[10000 + 10]*/, int go, int ba , int sa)
{
	if (puyo[go].col == puyo[ba].col && puyo[go].cn + puyo[ba].cn >= 4)
	{
		sa += puyo[go].cn + puyo[ba].cn;

		if (go - 1 >= 0 && ba < pn)
		{
			return chek(pn, go - 1, ba + 1, sa);
		}

	}

	return sa;
}

Measured memory_bytes: 3184
import math

def main():
    a,b,h,m = map(int, input().split())
    l_hand = 6 * m
    s_hand = 30 * h + m / 2
    theta = abs(l_hand - s_hand)

    if theta > 180:
        theta = 360 - theta
    
    cos_theta = math.cos(math.radians(theta))
    
    ans = a ** 2 + b ** 2 - 2 * a * b * cos_theta
    print(math.sqrt(ans))

if __name__ == "__main__":
    main()


Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
#define ll      long long
#define hell    1000000007
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb      push_back


int main()
{
	ios;
	ll n;
	set<string> s1;
	cin>>n;
	string s;
	while(n--)
	{
		cin>>s;
		s1.insert(s);
	}
	cout<<s1.size();
}

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

int main() {
  int N, K;
  cin >> N >> K;
  long long zero = 0, half = 0;
  for (int i = 1; i <= N; i++) {
    if (i % K == 0) zero++;
    if (K % 2 == 0 && i % K == K / 2) half++;
  }
  cout << zero * zero * zero + half * half * half << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>

using namespace std;

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A&lang=jp
// スタック

vector<string> split(const string &s, char delimiter) {
    vector<string> elements;
    stringstream ss(s);
    string item;
    while (getline(ss, item, delimiter)) {
        if (!item.empty()) {
            elements.push_back(item);
        }
    }
    return elements;
}

class Stack {
private:
    int top;
    vector<int> array;

public:

    void initialize() {
        top = -1;
        array = {};
    }

    bool isEmpty() {
        return array.size() == 0;
    }


    void push(int number) {
        array.push_back(number);
        ++top;
    }

    int pop() {
        int number = array[top];
        array.pop_back();
        --top;
        return number;
    }
};


int main() {

    string s;
    getline(cin, s);

    vector<string> array = split(s, ' ');

    Stack stack;
    stack.initialize();

    for (int i = 0; i < array.size(); ++i) {
        string str = array[i];
        if (str == "+") {
            int number1 = stack.pop();
            int number2 = stack.pop();
            stack.push(number2 + number1);
        } else if (str == "-") {
            int number1 = stack.pop();
            int number2 = stack.pop();
            stack.push(number2 - number1);
        } else if (str == "*") {
            int number1 = stack.pop();
            int number2 = stack.pop();
            stack.push(number2 * number1);
        } else {
            int number;
            number = atoi(str.c_str());
            stack.push(number);
        }
    }

    cout << stack.pop() << endl;

    return 0;
}




Measured memory_bytes: 3244
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n,d;
    cin>>n>>d;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        int x,y;
        cin>>x>>y;
        int res = sq(x) + sq(y);
        if(res>sq(d))
            continue;
        ans++;
    }
    cout<<ans;


    printclock;
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

void solve(int m,int n){
    set<pii> st;
    for(int i=-200;i<=200;i++){
        for(int j=-200;j<=200;j++){
            int t1 = i*m + j*n;
            int t2 = i*n - j*m;
            int ij = i*i + j*j;
            if(ij==0) continue;
            if(t1 % ij == 0 and t2 % ij == 0) st.insert(pii(i,j));
        }
    }

    //cout << st << endl;

    if(st.size()==8){
        cout << "P" << endl;
    }else{
        cout << "C" << endl;
    }
}

int main(){
    int N;
    cin >> N;
    rep(i,N){
        int m,n;cin>>m>>n;
        solve(m,n);
    }
}

Measured memory_bytes: 3092