akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        long n = scanner.nextLong();
        Set<Long> divisors = new TreeSet<>();
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                divisors.add(i);
                divisors.add(n / i);
            }
        }

        long ans = 0;
        for (long divisor : divisors) {
            long m = n / divisor - 1;
            if (m != 0 && n / m == n % m) {
                ans += m;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22568
#include<bits/stdc++.h>
#define ll long long int
#define sz  200010
using namespace std;


ll cnt[sz];
ll num[sz];




int main()
{

  ll n,k,q,i,j,a,b,l,r,x;

  cin>>n>>k>>q;

  for(i=1;i<=n;i++)num[i]=k;

  while(q--)
  {
      cin>>x;
      a=1;
      b=x-1;
      cnt[a]=cnt[a]-1;
      cnt[b+1]=cnt[b+1]+1;

       a=x+1;
       b=n;
       cnt[a]=cnt[a]-1;
       cnt[b+1]=cnt[b+1]+1;



  }


  for(i=1;i<=n;i++)
  {
      cnt[i]=cnt[i]+cnt[i-1];
    //  cout<<cnt[i]<<endl;
  }

  for(i=1;i<=n;i++)
  {
      num[i]=num[i]+cnt[i];

      if(num[i]>0)cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
  }

  return 0;
}



Measured memory_bytes: 2176
//package Test;

import java.util.*;

public class Main {

    static class Solution {

        void solve(int s){
            if(s < 3) {
                System.out.println(0);
                return;
            }
            int mod = 1000000007;
            int[] dp = new int[s + 1];
            dp[3] = 1;
            for(int i = 4; i <= s; i++) {
                for(int j = 3; j <= i - 3; j++) {
                    dp[i] = (dp[i] + dp[j]) % mod;
                }
                dp[i] = (dp[i] + 1) % mod;
            }
            System.out.println(dp[s]);
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int s = scanner.nextInt();
        Solution solution = new Solution();
        solution.solve(s);

    }
}


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

int main() {
  std::string a, b;
  std::cin >> a;
  b.resize(a.size());
  transform(a.begin(), a.end(), b.begin(), toupper);
  if (a == b) {
    std::cout << "A\n";
  } else {
    std::cout << "a\n";
  }
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
using  namespace std;
typedef long long lint;
typedef pair<lint, lint> P;

const int MAX_N = (int)1e5 + 5;
P A[MAX_N];

int main()
{
	lint N, M; cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i].first >> A[i].second;

	sort(A, A + N);

	lint i, Sum = 0, Ans = 0;
	for (i = 0; i < N; i++) {
		Sum += A[i].second;
		if (Sum <= M)
			Ans += A[i].first*A[i].second;
		if (Sum == M)
			break;
		else if (Sum > M) {
			Ans += A[i].first*(A[i].second - Sum + M);
			break;
		}
	}
	cout << Ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807/5;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int a,b;
int main(){
	cin>>a>>b;
	int t=a-2*b;
	if(t<0){
		cout<<0<<endl;
	}else{
		cout<<t<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#nm = '4 3'.split(' ')
#print(abc)
nm = input().split(' ')
vv = []
for i in range(int(nm[1])):
    a = input().split(' ')
    vv.append(int(a[0]))
    vv.append(int(a[1]))

for i in range(int(nm[0])):
    c = vv.count(1+i)
    if c != 0:
        print(c)
    else:
        print('0')
            


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (ll i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000000
#define ll long long
#define P pair<int,int>
#define cout_set(n) cout << setprecision(10) << (n) << endl; 
const double PI=3.14159265358979323846;
using namespace std;
const int mod = 1000000007; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

ll lt[MAX+1]={};

signed main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll x[4] = {a*c,a*d,b*c,b*d};
    ll max = x[0];
    rep(i,4){
        if(max < x[i]) max = x[i];
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 3612
import collections
N  = int (input())
nums = list(map(int,input().split(" ")))
MOD = 998244353
di = collections.defaultdict(lambda :0)
for num in nums:
    di[num] += 1


ans = 1 if nums[0] == 0 else 1
ans = 0 if 0 in nums[1:]  else 1
bottom = min(nums)
top= max(nums)
for d in range(1,top + 1):
    ans *= pow(di[d - 1] ,di[d ],MOD)


print(ans % MOD)

Measured memory_bytes: 19936
N = int(input())
MOD = 10**9 + 7

cnt = 1
j = 1
runner = 0

for x in map(int, input().split()):
  cnt *= j
  cnt %= MOD
  if runner >= x:
    runner = x
  else:
    j += 1
    runner += 2

print(cnt)

Measured memory_bytes: 11064
#include<bits/stdc++.h>
using namespace std;
int TEST=0,CASE=1;
#define         pf              printf
#define         si(x)           scanf("%d",&x)
#define         si2(x,y)        scanf("%d %d",&x,&y)
#define         si3(x,y,z)      scanf("%d %d %d",&x,&y,&z)
#define         sl(x)           scanf("%lld",&x)
#define         sl2(x,y)        scanf("%lld %lld",&x,&y)
#define         sl3(x,y,z)      scanf("%lld %lld %lld",&x,&y,&z)
#define         sd(x)           scanf("%lf ",&x)
#define         pb(x)           push_back(x)
#define         mp(x,y)         make_pair(x,y)
#define         clr(x,y)        memset(x,y,sizeof(x))
#define         all(x)          x.begin(),x.end()
#define         MX              401000
#define         left            (indx<<1)
#define         right           left+1
#define         mid             ((l+r)>>1)
#define         call            left,l,mid
#define         lnd             tree[left]
#define         calr            right,mid+1,r
#define         rnd             tree[right]
#define         cnd             tree[indx]
#define         speed           (ios::sync_with_stdio(false),cin.tie(0))
#define         fpoint(x)       (cout.precision(x),cout<<fixed)
#define         FOR(i,n)       	for(int i=1;i<=n;++i)
#define         FOR0(i,n)      	for(int i=0;i<n;++i)
#define		dx		xx+dirx[i]
#define		dy		yy+diry[i]
long long int         mod  =    1000000007LL;
const long double     pi   =    2.0*acos(0.0);
typedef long long int ll;
typedef long double ld;
int dirx[9]={0,0,0,-1,+1,+1,+1,-1,-1};
int diry[9]={0,-1,+1,0,0,-1,+1,-1,+1};
struct vpair{
        int a,b;
        vpair(int a,int b){this->a=a,this->b=b;}
};
bool cmp(int &a,int &b){
        return a<b;                ///ascending order
        return a>b;                ///descending order
}
int n,m,a,b,c,d,k,x,y,z,ans=0,total=0;
int arr[300001];
string s;
vector<int> v;
int main(void){
	cin>>a>>b>>c;
	if(a*c<=b){
		cout<<c<<endl;
	}else{
		cout<<(b/a)<<endl;
	}
        return 0;
}

/**
"G:\Work Station\OnlineJudge\Atcoder\A.cpp"
**/


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a_b = sc.nextLine().split(" ").map { Integer.parseInt(it) }
    val pmx = mutableListOf<Int>()
    pmx.add(a_b[0] + a_b[1])
    pmx.add(a_b[0] - a_b[1])
    pmx.add(a_b[0] * a_b[1])
    println(pmx.max())
}

Measured memory_bytes: 36088
# include "algorithm"
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;

int N,K,H[maxm];

int main(){
	register int i,Ans;
	scanf("%d%d",&N,&K);
	for(i=1;i<=N;i++) scanf("%d",H+i);
	sort(H+1,H+1+N);
	Ans=H[N];
	for(i=K;i<=N;i++){
		Ans=min(Ans,H[i]-H[i-K+1]);
	}
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, t; cin >> n >> t;
	vector<pair<int, int>> c(n);
	rep(i, 0, n - 1)cin >> c[i].first >> c[i].second;
	sort(all(c));
	vector<vector<int>> dp(6100, vector<int>(6100, 0));
	int ans = 0;
	rep(i, 0, n - 1)rep(j, 0, t - 1)
	{
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		if (c[i].first + j < t)
		{
			dp[i + 1][j + c[i].first] = max(dp[i][j + c[i].first], dp[i][j] + c[i].second); 
		}
		ans = max(ans, dp[i][j] + c[i].second);
	}
	cout << ans << endl;
}


Measured memory_bytes: 146048
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	ll n,o=0,min=1000000000,c=0;
	ll a[201];

	cin>>n;

	for(ll i=1; i<n+1; ++i){
		cin>>a[i];
	}

	for(ll i=1; i<n+1; ++i){
		o=a[i];
		c=0;
		rep(j,50000000){
			if(o%2==0){
				c++;
				o=o/2;
			}else{
				break;
			}
		}
		if(c<min){
			min=c;
		}
	}
	cout<<min<<endl;

	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for n != 0 {
		arr := make([]int, n)
		for i := range arr {
			fmt.Scan(&arr[i])
		}
		sort.Ints(arr)

		sum := 0
		for i := 1; i < len(arr)-1; i++ {
			sum += arr[i]
		}
		fmt.Println(sum / (n - 2))
		fmt.Scan(&n)
	}
}



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

bool slove(string s)
{
  if(s.size()<6)
    return false;
  int count[3]={0,0,0};
  for(int i=0;i<s.size();i++)
    {
      if(s[i]>='0' &&s[i]<='9')
        count[0]++;
      if(s[i]>='a' &&s[i]<='z')
        count[1]++;
      if(s[i]>='A' &&s[i]<='Z')
        count[2]++;
    }
  for(int i=0;i<3;i++)
   {
     if(count[i]<=0)
       return false;
   }
  
  return true;

}
int main()
{
  string s;
  for(;cin>>s;)
    {
      if(slove(s))
        cout<<"VALID"<<endl;
      else
        cout<<"INVALID"<<endl;
    }
}

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

using namespace std;

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

    int mx=0;
    for(int i=0;i<=100000;i++)
    {
        mx= max(mx,cnt[i]+cnt[i+1]+cnt[i+2]);
    }

    cout<<mx;

}


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

using namespace std;

const int MAXN = 2e5 + 10;

int n, m;
vector<int>	adj[MAXN];
bool vis[MAXN];

void dfs(int v){
	if (vis[v])	return;
	vis[v] = 1;
	for (int u:adj[v])
		dfs(u);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		int sz;	cin >> sz;
		adj[i].resize(sz);
		for (int j = 0; j < sz; j++){
			cin >> adj[i][j], adj[i][j] += n-1;
			adj[adj[i][j]].push_back(i);
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; i++)
		if (!vis[i])
			dfs(i), cnt++;
	if (cnt == 1)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;
constexpr int MAX_X = 1000000;

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

  int n;
  cin >> n;
  vector<int> xs(n);
  vector<int> count_map(MAX_X + 1);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
    count_map[xs[i]]++;
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (count_map[1] >= 1) {
    if (count_map[1] == 1) {
      cout << 1 << endl;
      return 0;
    } else {
      cout << 0 << endl;
      return 0;
    }
  }

  int solution = 0;
  for (int i = 0; i < n; i++) {
    if (count_map[xs[i]] >= 2) continue;
    bool valid = true;
    for (int d = 2; d * d <= xs[i]; d++) {
      if (xs[i] % d == 0) {
        int e = xs[i] / d;
        if (count_map[d] || count_map[e]) {
          valid = false;
        }
      }
    }
    if (valid) {
      solution++;
    }
  }
  cout << solution << endl;
}

Measured memory_bytes: 7932
#include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define trace(x) cerr<<x<<END;
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, b, a) for(int i = (b); i > (a); --i) 
const int mod = 1e9+7;
const int mod1 = 998244353;
const int inf = 92233720000000000ll;
const int nax = 500005;
int fac[nax],inv[nax],facinv[nax];
void preprocess(){
   facinv[0] = inv[0] = fac[0] = 1;
   facinv[1] = inv[1] = fac[1] = 1;
   loop(i,2,nax)
    inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;
   loop(i,2,nax){
    fac[i] = (i*fac[i-1])%mod;
    facinv[i] = (inv[i]*facinv[i-1])%mod;
   }
}
int ncr(int n,int r){
   if(r<0 || n<0 || r>n)
    return 0;
   else 
    {
      int curr = fac[n];
      (curr *= facinv[r])%=mod;
      (curr *= facinv[n-r])%=mod;
      return curr;
    }
}
int n,m;
void solve()
  {
   preprocess();
   cin>>n>>m;
   int ans = 0;
   int one = 1;
   loop(i,0,n+1)
    {
      ans += one*((ncr(n,i) * ncr(m-i,n-i))%mod * fac[n-i])%mod;
      ans %= mod;
      if(ans<0)
         (ans+=mod)%=mod;
      one = -one;
    }
    //cout<<ans<<END;
    if(ans<0)
         (ans+=mod)%=mod;
    ans %= mod;
    ans = ((ans * ncr(m,n))%mod * fac[n])%mod;  
    cout<<ans;
  }
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
     solve();
  //cerr<<1.0*clock();
  return 0;
} 

Measured memory_bytes: 15356
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;


int main() {
    int n;
    cin >> n;
    vector<ll> as(n);
    rep(i, n) cin >> as[i];
    ll tot = 0;
    int sg = 1; 
    rep(i, n) {
        tot += as[i] * sg;
        sg *= -1;  
    }
    vector<ll> ans(n);
    ans[0] = tot;
    rep(i, n-1) ans[i+1] = 2*as[i]-ans[i];
    rep(i, n) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define l_ength size
const int mod = 1000000007;
using ll = long long;
const ll infll = (1ll<<60);
using namespace std;

ll a[410];
ll s[410];
// d[x][y] := 半開区間 [x, y) のスライムが全て合体して 1 匹になるときのコストの最小値
ll d[410][410];
// bscht[x][y] := 半開区間 [x, y) の dp をすでに求めたかどうか
bool bscht[410][410];

ll dp( int x, int y ){
	if( y - x == 1 ) return 0;
	if( bscht[x][y] ) return d[x][y];
	else bscht[x][y] = true;
	ll sum = s[y]-s[x];
	ll cost = infll;
	for( int k = x+1; k < y; ++k ){
		cost = min( cost, dp(x, k)+dp(k, y) );
	}
	return d[x][y] = sum + cost;
}

int main(){
	int n; cin >> n;
	for( int i = 0; i < n; ++i ) cin >> a[i];
	for( int i = 0; i < n; ++i ) s[i+1] = s[i] + a[i];
	cout << dp(0, n) << endl;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void) {
  int num,i,a = 1,u,q = 0;
  char ch,chara = '@';
  int counter[26];

  for(i = 0; i < 26; i++){
    counter[i] = 0;
  }

  while(1){
    scanf(" %c",&ch);
    if(a == 3){
      if(ch == 'i'){
        u = 1;
      }
    }
    if(a == 11 && u == 1){
      break;
    }
    if(a == 1){
      if(ch == 'A'){
        u = 2;
      }
    }
    if(a == 10 && u == 2){
      counter['z' - 'a']++;
      break; 
    }
    if(a == 1){
      if(ch == '3'){
        break;
      }
    }
    if(a == 3){
      if(ch == 'e'){
        u == 4;
      }
    }
    if(ch == '.'){
      q++;
    }
    if(q == 9){
      break;
    }
    if(65 <= ch && ch <= 90){
      num = ch - 'A';
    }
    else{
      num = ch - 'a';
    }
    counter[num]++;
    a++;
  }
  for(i = 0; i < 26; i++){
    ch = i + 'a';
    printf("%c : %d\n",ch,counter[i]);
  }
  return 0;
}


Measured memory_bytes: 2044
#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>;

const int INF = 1001001001;
//上下左右を考える時につかうやつ
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(si,h)rep(sj,w) {
    if (s[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) { 
      //λ式，名前のない関数　＆をいれると{}のそとの変数にもアクセスできる
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i,j)); // .emplace(i,j)
    };
    update(si,sj,0);
    while (!q.empty()) {
      int i = q.front().first;
      int j = q.front().second; q.pop();
      rep(dir, 4) {
        int ni = i+di[dir], nj= j+dj[dir];
        if (ni<0 || ni>=h || nj<0 || nj>=w) continue;
        if (s[ni][nj] == '#') continue;
        update(ni,nj,dist[i][j]+1);
      }
    }
    //ここまででBFSは終わり
    rep(i,h)rep(j,w) {
      if (dist[i][j]== INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
#define rep(i, n) for (int i = 0; i < n; i++)
 
int main(void) {
    string s;
    cin >> s;
    int ans = 0; // 数を数えるための変数。これが答えになる
    
    rep (i,3) {
      if (s[i] == '1') {
        ans++;
      }
    }
    cout << ans << endl;
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Int32.Parse(Console.ReadLine());
            HashSet<int> h = new HashSet<int>();
            int prev = s;
            for (int i=2;i<=1000000; i++)
            {
                h.Add(prev);
                prev = Calc(prev);
                if (h.Contains(prev))
                {
                    Console.WriteLine(i);
                    return;
                }              
            }
            
        }
        static int Calc(int n)
        {
            return (n % 2 == 0 ? n / 2 : 3 * n + 1);
        }
    }
}


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

using namespace std;

int main()
{
  string s[3] = {"Sunny", "Cloudy", "Rainy"};
  string t; cin >> t;
  for(int i = 0; i < 3; i++)
    if(t == s[i])
      return !(cout << s[(i+1)%3] << endl);
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int p[1005];
    int k,n;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    sort(p,p+n);
    for(int i=1;i<k;i++){
        p[i]+=p[i-1];
    }
    cout<<p[k-1];
    return 0;
}

Measured memory_bytes: 3652
# from pprint import pprint
# import math
# import collections

# n = int(input())
a, b, x = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

_a = a // x + 1
_b = b // x + 1

if a % x == 0:
    _c = 1
else:
    _c = 0

ans = _b - _a + _c

# print(_a, _b, _c, ans)
print(ans)


Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int w=n;
  int ans=0;
  int s[10];
  for(int i=1;i<11;i++){
      s[i]=n%10;
      n=(n-n%10)/10;
      ans+=s[i];
      if(n==0){
        break;  
      }
  }
  if(w%ans==0){
    cout<<"Yes"<<endl;  
  }
  else{
    cout<<"No"<<endl;  
  }
}

Measured memory_bytes: 256
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n,k;
vector<int> al[100005];
int w[100005];
priority_queue<ii,vector<ii>, greater<ii> > pq;

void rage(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	cin>>n;
	
	int a,b;
	rep(x,1,n){
		cin>>a>>b;
		al[a].push_back(b);
		al[b].push_back(a);
	}
	
	cin>>k;
	memset(w,-1,sizeof(w));
	rep(x,0,k){
		cin>>a>>b;
		w[a]=b;
		
		pq.push(ii(w[a],a));
	}
	
	while (!pq.empty()){
		int node=pq.top().se;
		pq.pop();
		
		for (auto &it:al[node]){
			if (w[it]==-1){
				w[it]=w[node]+1;
				pq.push(ii(w[it],it));
			}
			else{
				if (abs(w[it]-w[node])!=1) rage();
			}
		}
	}
	
	cout<<"Yes"<<endl;
	rep(x,1,n+1) cout<<w[x]<<endl;
}


Measured memory_bytes: 11516
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[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;
}

int main()
{
  INT(N);
  INT(C);
  vector<vector<ll>> A(N,vector<ll>(3));
  vector<vector<P>> channel(C,vector<P>());
  REP(i, N){
    REP(j, 3){
      cin >> A.at(i).at(j);
      if(j==0||j==1){
        A[i][j]*=2;
      }
    }
    A[i][2]--;
    channel[A[i][2]].push_back(make_pair(A[i][0],A[i][1]));
  }
  REP(i,C){
    sort(ALL(channel[i]));
  }
  vector<ll> imos(200010,0);

  REP(i,C){
    if(sz(channel[i])!=0){
      ll sta = channel[i][0].first-1;
      ll en = channel[i][0].second;
      FOR(j,1,sz(channel[i])){
        P x=channel[i][j];
        if(en!=x.first){
          imos[sta]++;
          imos[en]--;
          sta=x.first-1;
          en=x.second;
        }else{
          en=x.second;
        }
      }
      imos[sta]++;
      imos[en]--;
    }
  }
  
  ll MAX=0;
  ll sum = 0;
  REP(i,200010){
    sum+=imos[i];
    MAX=max(MAX,sum);
  }
  cout << MAX << endl;
}

Measured memory_bytes: 12716
#include <bits/stdc++.h>
using namespace std;
void output(char A,char C);
int main() {
char A,B,C;
  cin >> A >> B >> C; 
  output(A,C);}
void output(char A,char C){
  
if (A==C) {
  cout << "Yes" << endl;
}else {
  cout << "No" << endl;
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
long long weight[110];
long long value[110];
long long dp[110][100010];

int main() {
  int n,w; cin>>n>>w;
  for(long long i=0; i<n;i++){
    cin>>weight[i];
    cin>>value[i];
  }  
  for(int i=0;i<=w;i++){
    dp[0][i]=0;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<=w;j++){
      if(j-weight[i]>=0)   dp[i+1][j]=max(dp[i][j-weight[i]]+value[i],dp[i][j]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 80128
def input_from_console():
    a, b = map(int, input().split())
    return a, b


def solve(a, b):
    if a >= 13:
        return b
    elif a >= 6:
        return int(b / 2)
    return 0


def main():
    a, b = input_from_console()
    print(solve(a, b))


if __name__ == "__main__":
    import sys
    if sys.gettrace():
        check_cases()
    else:
        main()

Measured memory_bytes: 3064
#include <cstring>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

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

    ll a = gli();
    ll b = gli();
    ll k = gli();

    ll s = MIN(a, k);
    a -= s;
    k -= s;
    s = MIN(b, k);
    b -= s;

    cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(N)]
ac = 0
wa = 0
tle = 0
re = 0
for i in S:
  if i == "AC":
    ac += 1
  elif i == "WA":
    wa += 1
  elif i == "TLE":
    tle += 1
  else:
    re += 1
print("AC x {}".format(ac))
print("WA x {}".format(wa))
print("TLE x {}".format(tle))
print("RE x {}".format(re))

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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define f(t) for(ll i =0;i<t;i++)
#define bs(a,x) binary_search(a.begin(),a.end(),x)
#define ll long long int
#define ul unsigned long int
#define ld long double
#define umpi unordered_map<int,int> 
#define umpl unordered_map<ll,ll> 
#define vi vector<int>
#define vl vector<ll>
#define fill(a,p) memset(a,p,sizeof(a))
#define pb push_back
#define mod 1000000007
#define N 100005
#define all(a) a.begin(),a.end()
#define point pair<ll,ll>
#define endl "\n"

const int inf = 1000000007;
const ll linf = 1ll * inf * inf;
const ll MAXIMUM =2005;

inline ll mul(ll a, ll b){ return (a * 1ll * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c >= mod) c -= mod; return c; }
inline ll max(ll a, ll b){return a>b?a:b;}
inline ll minim(ll a, ll b){return a<b?a:b;}

struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

ll power(ll x, ll y,ll p) 
{ 
    ll res = 1;      
     x = x % p;    
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
            y = y>>1;  
            x = (x*x) % p;   
    } 
    return res; 
}

ll modInverse(ll n,ll p) 
{ 
    return power(n, p-2, p); 
} 


ll lcm(ll a,ll b){
  return (a*b)/__gcd(a,b);
}

bool comp(const point &p1,const point &p2){
	if(p1.first!=p2.first)return p1.first<p2.first;
	else return p1.second<p2.second;
}

string to(char x){
	string s(1,x);
	return s;
}

int main()
{
	fio;
	ll n;cin>>n;
	ll m;cin>>m;
	vector<vector<char>> grid(n,vector<char>(m));
	for(ll i=0;i<n;i++){
		for(ll j=0;j<m;j++){
			cin>>grid[i][j];
		}
	}
	vector<vector<ll>> dp(n,vl(m,0));
	dp[0][0]=1;
	for(ll i=0;i<n;i++){
		for(ll j=0;j<m;j++){
			if(grid[i][j]=='.'){
				if(i>0 && grid[i-1][j]!='#')dp[i][j]=add(dp[i][j],dp[i-1][j]);
				if(j>0 && grid[i][j-1]!='#')dp[i][j]=add(dp[i][j],dp[i][j-1]);
			}
		}
	}
	cout<<dp[n-1][m-1]<<endl;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)

int main(){


	lli a,b;
	cin>>a>>b;

	lli ans = -INF;
	ans = max(ans,a+b);
	ans = max(ans,a-b);
	ans = max(ans,a*b);

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner input=new Scanner(System.in);
        int a,b;
        while(true){
            a=input.nextInt();
            char op = input.next().charAt(0);
            b=input.nextInt();
        if(op == '?')break;
        else if (op == '+')
            System.out.println(a + b);
        else if ( op == '-')
            System.out.println(a - b);
        else if (op == '*')
            System.out.println(a * b);
        else if(op == '/')
            System.out.println(a / b);
        }
    }
}


Measured memory_bytes: 26176
//सत्यान्न प्रमदितव्यम्  ||
//Still, Taking my time to perfect the beats
//And I still got love for the streets, it's the A-D-D-U

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define nt _int128
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debugged cout<<"debugged\n";
#define inf 0x3f3f3f3f
#define LINF  0x3f3f3f3f3f3f3f3fll
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end() 

const ll mod = 999983;
#define mx 1000005
const ll mxi = 10005;

int main()
{
    fast_as_levi;
    ll k;
    cin>>k;
    ll a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            return cout<<"OK" , 0;
        }
    }
    cout<<"NG";
}

Measured memory_bytes: 3660
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        List<Long> a = new ArrayList<>();
        int n = sc.nextInt();
        for(int i = 0;i < n;i++){
            a.add(sc.nextLong());
        }
        long m = 1L;
        //        for(Long it : a){
        //            m = lcm(m,it);
        //        }
        //        //System.out.println("lcm = " +m);
        long answer = 0;
        for(int i = 0;i < n;i++){
            answer += a.get(i)-1;
        }
        System.out.println(answer);
    }
    public static long lcm(long a,long b){
        return a*b/gcd(a,b);
    }
    public static long gcd(long a,long b){
        if(b == 0){
            return a;
        }
        return gcd(b,a%b);
    }
}


Measured memory_bytes: 26152
N , M = (map(int , input().split()))
H = list(map(int , input().split()))
AB = [list(map(int, input().split())) for i in range(M)]
HH = {i+1 : H[i] for i in range(len(H))}

count = {i+1 : 0 for i in range(N)}
for i in AB:
    if HH[i[1]] > HH[i[0]]:
        count[i[0]] -= 1
    elif HH[i[1]] == HH[i[0]]:
        count[i[0]] -= 1
        count[i[1]] -= 1
    else:
        count[i[1]] -= 1
        
print(sum([1 for i in count.values() if i == 0]))

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long K) {
    rep(i, K) {
        if (B <= A) {
            B *= 2;
        } else if (C <= B) {
            C *= 2;
        }
    }
    if (A < B && B < C) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long K;
    scanf("%lld", &K);
    solve(A, B, C, K);
    return 0;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> original(n, vector<int>(n, 1e9)), adj;
    vector<pair<int, int>> edge;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c, a--, b--;
        original[a][b] = original[b][a] = c;
        edge.emplace_back(a, b);
    }
    adj = original;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                adj[j][k] = min(adj[j][k], adj[j][i] + adj[i][k]);
            }
        }
    }

    int ans = 0;
    for (auto& e : edge) {
        if (original[e.first][e.second] != adj[e.first][e.second]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,e) for(int i=s;i<e;i++)
#define endl '\n'
int main(){
    string s,t;
    cin>>s>>t;
    bool flag=false;
    for(int i=0;i<s.size();i++){
        if(s==t)flag=true;
        s=s.back()+s.substr(0,s.size()-1);
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A == B && B == C) {
    cout << "No" << endl;
  } else if (A == B || B == C || C == A) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define resort(v) sort((v).rbegin(), (v).rend())
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
//const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

/*signed*/int main(void) {
    int x; cin >> x;
    int a = lcm(x, 360);
    cout << a / x << endl;
}

Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std;

#define white 0
#define gray 1

int M[101][101];
int d[101],color[101];
queue<int> q;
int a,n;

void bfs(int u){
  color[u]=gray;
  q.push(u);
  while(!q.empty()){
    a=q.front();
    q.pop();
    for(int v=1;v<=n;v++){
      if(M[a][v]==1 && color[v]==white){
        color[v]=gray;
        d[v]=d[a]+1;
        q.push(v);
      }
    }
  }
}

int main(){
  int x,y,z;
  cin>>n;
  
  rep(i,101){
    rep(j,101) M[i][j]=0;
  }
  
  rep(i,101){
    d[i]=-1;
    color[i]=white;
  }
  d[1]=0;
  
  rep(i,n){
    cin>>x>>y;
    rep(j,y){
      cin>>z;
      M[x][z]=1;
    }
  }
  
  bfs(1);
  for(int i=1;i<n+1;i++) cout<<i<<" "<<d[i]<<endl;
  
  return 0;
}


Measured memory_bytes: 3156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int T = s.nextInt();
        String s1;
        int ac,wa,tle,re;
        ac=tle=re=wa=0;
        while (T-- > 0) {
            s1=s.next();

            if(s1.equals("AC"))
                ac++;
            else if(s1.equals("WA"))
                wa++;
            else if(s1.equals("RE"))
                re++;
            else
                tle++;
        }
        System.out.println("AC x "+ac);
        System.out.println("WA x "+wa);
        System.out.println("TLE x "+tle);
        System.out.println("RE x "+re);

    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 38436
#include<iostream>
//#include<numbers>
#include<cmath>
#include <iomanip>
using namespace std;
const double PI=3.14159265358979323846264338327950;
int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    cout << fixed << setprecision(25) << sqrt(pow(A, 2)+pow(B, 2)-2.0*A*B*cos(2.0*PI*(H/12.0+(M/12.0)/60.0-M/60.0)));
}


Measured memory_bytes: 4288
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>

using ll = long long;

int main() {
    std::string S;
    std::cin >> S;
    int n = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '+') {
            n++;
        }
        else {
            n--;
        }
    }
    std::cout << n << std::endl;
    return 0;
}


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

int main() {
	
	string s;
	getline(cin, s);
	
	for (int i = 0; i < s.size(); i++) {
		if ((s[i] >= 'a')&&(s[i] <= 'z')) s[i] -= 32;
		else if ((s[i] >= 'A')&&(s[i] <= 'z')) s[i] += 32;
	}
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define int long long int

char arr[405][405];
bool vis[405][405];
int h, w;
int cb;
int cw;

bool f(int i, int j, int l, int m){
	if(l<0 || l>=h || m<0 || m>=w){
		return 0;
	}
	if(vis[l][m]==1){
		return 0;
	}
	if(arr[i][j]==arr[l][m]){
		return 0;
	}
	return 1;
}

void dfs(int i, int j){
	vis[i][j]=1;
	if(arr[i][j]=='#'){
		cb++;
	}
	else{
		cw++;
	}
	if(f(i, j, i+1, j)){
		dfs(i+1, j);
	}
	if(f(i, j, i, j+1)){
		dfs(i, j+1);
	}
	if(f(i, j, i-1, j)){
		dfs(i-1, j);
	}
	if(f(i, j, i, j-1)){
		dfs(i, j-1);
	}
}


main() {
	cin>>h>>w;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			cin>>arr[i][j];
		}
	}
	int ans=0;
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(vis[i][j]==0){
				dfs(i, j);
				ans+=(cb*cw);
				cb=0;
				cw=0;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 13852
#include <algorithm>
#include <cstdio>
#include <ctype.h>
#include <functional>
#include <iostream>
#include <cassert>
#include <cfloat>
#include <climits>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#define int long long
using namespace std;

signed main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << min(A*B, min(B*C, C*A)) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>

using namespace std;

int main(){
  int in;
  cin >> in;
  char trash;
  scanf("%c",&trash);
  for(int i = 0; i < in; i++){
    string str;
    getline(cin,str);
    string out;
    out += str[0];
    for(int j = 1; j < str.length(); j+=3){
      if(str[j+1] == '>'){
	int status = 1;
	for(int k = 0; k < out.length(); k++){
	  if(out[k] == str[j+2]) status = 0;
	}
	if(status) out += str[j+2];
      }
      if(str[j] == '<'){
	int status = 1;
	for(int k = 0; k < out.length(); k++){
	  if(out[k] == str[j+2]) status = 0;
	}
	if(status){
	  string sub;
	  sub += str[j+2];
	  sub += out;
	  out = sub;
	}
      }
    }
    cout << out << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


class BipartiteMatching:
    def __init__(self, N, M):
        self.N = N
        self.M = M
        self.pairA = [-1] * N
        self.pairB = [-1] * M
        self.edge = [[] for _ in range(N)]
        self.was = [0] * N
        self.iter = 0

    def add(self, s, t):
        self.edge[s].append(t)

    def _DFS(self, s):
        self.was[s] = self.iter
        for t in self.edge[s]:
            if self.pairB[t] == -1:
                self.pairA[s] = t
                self.pairB[t] = s
                return True
        for t in self.edge[s]:
            if self.was[self.pairB[t]] != self.iter and self._DFS(self.pairB[t]):
                self.pairA[s] = t
                self.pairB[t] = s
                return True
        return False

    def solve(self):
        res = 0
        while True:
            self.iter += 1
            found = 0
            for i in range(self.N):
                if self.pairA[i] == -1 and self._DFS(i):
                    found += 1
            if not found:
                break
            res += found
        return res


if __name__ == "__main__":
    N = int(input())
    AB = [list(map(int, input().split())) for _ in range(N)]
    CD = [list(map(int, input().split())) for _ in range(N)]

    match = BipartiteMatching(N, N)

    for i, (a, b) in enumerate(AB):
        for j, (c, d) in enumerate(CD):
            if a < c and b < d:
                match.add(i, j)
    ans = match.solve()
    print(ans)


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

int main(){
  int n,m;
  int cost[1001],judge[1001],ans[1001] = {0};
  cin >> n >> m;
  for(int i=0;i<n;i++) cin >> cost[i];
  for(int j=0;j<m;j++) cin >> judge[j];
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      if(cost[j] <= judge[i]){
	ans[j]++; break;
      }
    }
  }
  int maxi = 0,ma = 0;
  for(int i=0;i<n;i++){
    if(ma < ans[i]){ maxi = i + 1; ma = ans[i]; }
  }
  cout << maxi << endl;
}

Measured memory_bytes: 1172
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            a.add(scanner.nextInt());
        }
        boolean flag = true;
        int count = 0;
        while (flag) {
            flag = false;
            for (int j = n - 1; j >= 1; j--) {
                if (a.get(j) < a.get(j - 1)) {
                    int tmp = a.get(j);
                    a.set(j, a.get(j - 1));
                    a.set(j - 1, tmp);
                    count++;
                    flag = true;
                }
            }
        }
        for (int i = 0; i < a.size(); i++) {
            System.out.print(a.get(i));
            if (i != a.size() - 1) {
                System.out.print(" ");
            }
        }
        System.out.println("");
        System.out.println(count);
        scanner.close();
    }
}



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

int main() {
  string s;
  cin >> s;
  int a = 0;
  int b = 0;
  int c = 0;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == 'a'){
      a++;
    }
    if(s.at(i) == 'b'){
      b++;
    }
    if(s.at(i) == 'c'){
      c++;
    }
  }
  if(a == 1 && b == 1 && c == 1){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 256
n,k = input().split()
hate_num = input().split()
num = int(n)
boo = False
while(boo == False):
  dec = []
  for i in str(num):
    dec.append(i not in hate_num)
    
  if(False not in dec):
    boo = True
  num += 1
    
print(num-1)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 20:55:28 2020

@author: naoki
"""

import itertools
N, M = map(int, input().split())

option = 0
if N>1:
    #print(list(itertools.combinations(range(N), 2)))
    option += len(list(itertools.combinations(range(N), 2)))
if M>1:
    option += len(list(itertools.combinations(range(M), 2)))
print(option)

Measured memory_bytes: 38640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        int remain = H * W - (h * W + w * H - h * w);
        
        System.out.println(remain);
	}	
}

Measured memory_bytes: 22356