akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=100005;

struct Edge
{
	int v,dir,id;
	Edge(int _v,int _dir,int _id)
	{v=_v;dir=_dir;id=_id;}
};

int n,m;
vector<Edge> adj[MAXN];
bool vis[MAXN],visE[MAXN];
int col[MAXN],cnt[3];
int vcnt,ecnt;
bool conflict;

void dfs(int u)
{
	vis[u]=true;
	vcnt++;
	cnt[col[u]]++;
	for(auto e:adj[u])
		if(!visE[e.id])
		{
			visE[e.id]=true;
			ecnt++;
			if(!vis[e.v])
			{
				col[e.v]=(col[u]+e.dir+3)%3;
				dfs(e.v);
			}
			else if(col[e.v]!=(col[u]+e.dir+3)%3)
				conflict=true;
		}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		adj[a].push_back(Edge(b,1,i));
		adj[b].push_back(Edge(a,-1,i));
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
		if(!vis[i])
		{
			cnt[0]=cnt[1]=cnt[2]=0;
			vcnt=ecnt=0;
			conflict=false;
			dfs(i);
			if(conflict)
				ans+=1LL*vcnt*vcnt;
			else if(cnt[0]==0||cnt[1]==0||cnt[2]==0)
				ans+=ecnt;
			else
				ans+=1LL*cnt[0]*cnt[1]+1LL*cnt[1]*cnt[2]+1LL*cnt[0]*cnt[2];
		}
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 11008
#include<cstdio>
#include<cstring>
using namespace std;
int n;
char s[15];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if(n&1)
	{
		printf("No\n");
	}
	else
	{
		for(int i=1;i<=n;i+=2)
		{
			if(s[i]!='h')
			{
				printf("No\n");
				return 0;
			}
		}
		for(int i=2;i<=n;i+=2)
		{
			if(s[i]!='i')
			{
				printf("No\n");
				return 0;
			}
		}
		printf("Yes\n");
	}
	return 0;
}

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

ll h,w;
ll dp[111][111];

int main(){
    cin >> h >> w;
    char s[h][w];
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            cin >> s[i][j];
        }
    }
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            dp[i][j]=1e9;
        }
    }
    if(s[0][0]=='#') dp[0][0]=1;
    else dp[0][0]=0;
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++){
            if(i-1>=0){
                if(s[i-1][j]=='.'&&s[i][j]=='#') dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
                else dp[i][j]=min(dp[i][j],dp[i-1][j]);
            }
            if(j-1>=0){
                if(s[i][j-1]=='.'&&s[i][j]=='#') dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
                else dp[i][j]=min(dp[i][j],dp[i][j-1]);
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}  

Measured memory_bytes: 3736
#include<cmath>
#include<cstdio>

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

using namespace std;

const double EPS=1e-8;

int main(){
	int n; scanf("%d",&n);
	int x[50],y[50];
	rep(i,n) scanf("%d%d",x+i,y+i);

	if(n%2==1){ puts("NA"); return 0; }

	double gx=0,gy=0;
	rep(i,n) gx+=x[i], gy+=y[i];
	gx/=n;
	gy/=n;

	rep(i,n){
		if(abs((x[i]+x[(i+n/2)%n])/2.0-gx)<EPS
		&& abs((y[i]+y[(i+n/2)%n])/2.0-gy)<EPS);
		else{
			puts("NA");
			return 0;
		}
	}

	printf("%.9f %.9f\n",gx,gy);

	return 0;
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
#define pb push_back
#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
#define INF 93193111451418101
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
  ll a, b;
  cin >> a >> b;
  if (a == b && a == 1)
    return !printf("%lld\n", 1);
  if (a > b)
    swap(a, b);
  if (a == 1)
    return !printf("%lld\n", b - 2);
  ll ans = (a - 2) * (b - 2);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long res = 0;
    int m, n, ai;
    cin >> m >> n;
    int i = 0;
    while (i++ < n) {
        cin >> ai;
        res += ai;
    }

    cout <<  ((m >= res) ? (m - res) : -1) << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
long long dp[101][100001];
long long solve(long long W,long long w[],long long p[],long long n,long long N)
{
    if(W<=0)
    return 0;
    if(n>=N)
    return 0;
    if(w[n]>W)
        return solve(W,w,p,n+1,N);
    if((dp[n][W])!=-1)
        return dp[n][W];
    long long ans=0;
    ans=max(p[n]+solve(W-w[n],w,p,n+1,N),solve(W,w,p,n+1,N));
    return dp[n][W]=ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n,W;
    cin>>n>>W;
    long long w[n],i,p[n],j;
    dp[0][0]=-1;
    for(i=0;i<=100;i++)
    {
        for(j=0;j<=100000;j++)
        dp[i][j]=-1;
    }
    for(i=0;i<n;i++){
        cin>>w[i];
        cin>>p[i];
    }
    cout<<solve(W,w,p,0,n);
}

Measured memory_bytes: 79232
#include <iostream>
#include <algorithm>  
#include <vector>
#include <map> 

using namespace std;
#include <math.h>    // for sqrt
#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

int main() {
    int n; cin >> n;
    int vec[100] = {};
    repeat(i, n)
      cin >> vec[i];

    int sum = 0;
    for (int i = 0; (i) < (n); ++ (i)) {
      for (int j = i; (j) < (n); ++ (j)) {
        if (i == j) continue;
        sum += vec[i] * vec[j];
      }
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int cnt[5];
  cnt[1] = 0; cnt[2] = 0; cnt[3] = 0; cnt[4] = 0;
  for (int i = 0; i < 6; i++) {
    int t; cin >> t;
    cnt[t] += 1;
  }
  bool check = true;
  for (int i = 1; i <= 4; i++) {
    if (!(cnt[i] == 1 || cnt[i] == 2))
      check = false;
  }
  cout << (check ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 133
//A - T or T
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
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;}

bool data[500][500];

int main(){
	int n;
	while(cin >> n,n){
		int w,h,ww,wh;
		cin >> w >> h;
		REP(i,500) REP(j,500) data[i][j] = false;
		REP(i,n){
			int x,y;
			cin >> x >> y;
			data[x-1][y-1] = true;
		}
		int ans = 0;
		cin >> ww >> wh;
		REP(i,w-ww+1){
			REP(j,h-wh+1){
				int cnt = 0;
				for(int k=i;k<i+ww;k++){
					for(int m=j;m<j+wh;m++){
						if(data[k][m]) cnt++;
					}
				}
				ans = max(ans,cnt);
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1404
module Main where

import Data.List
import Control.Monad
import Control.Monad.ST (runST)
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Vector.Mutable as MV
import qualified Data.Vector as V
import Data.Function (fix)


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [(Int, Int)] -> [(Int, Int)] -> [Int]
solve n abList pxList = runST $ do
        graph <- MV.replicate (n + 1) []
        forM_ abList $ \(a, b) -> do 
            MV.modify graph (a:) b
            MV.modify graph (b:) a
        points <- MV.replicate (n + 1) 0
        forM_ pxList $ \(p, x) -> MV.modify points (+x) p
        ans <- MV.replicate (n + 1) 0
        let dfs = fix $ \next point parent -> do
                mine <- MV.read points point
                MV.modify ans (+mine) point
                sons <- MV.read graph point
                myPoint <- MV.read ans point
                forM_ sons $ \son ->
                    if son == parent then return ()
                    else do 
                        MV.modify ans (+myPoint) son
                        next son point
        dfs 1 (negate 1)
        frozenAns <- V.freeze ans
        pure . tail $  V.toList frozenAns


main = do
    (n, q) <- readTuple2
    abList <- replicateM (n - 1) readTuple2
    pxList <- replicateM q readTuple2
    putStrLn $ unwords  $ show <$> solve n abList pxList


Measured memory_bytes: 180476
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#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 Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    int num;
    cin >> num;
    a.at(i) = num;
  }
  long long sum = 0;
  for (int i = 0; i < n-1; i++) {
    if (a.at(i) > a.at(i+1)) {
      sum += a.at(i)-a.at(i+1);
      a.at(i+1) = a.at(i);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 4028
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>

#define reps(i, j, k) for (int i = (j); i < (k); i++)
#define rep(i, j) reps(i, 0, j)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

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

	int minimum = 100000;
	rep(i, N) {
		int A;
		cin >> A;

		int count = 0;
		while ((A % 2) == 0) {
			count++;
			A /= 2;
		}

		minimum = min(count, minimum);
	}

	cout << minimum << endl;

	return 0;
}

Measured memory_bytes: 256
// ITP1_7_D:   Matrix Multiplication
// 2017.7.27

#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101][101];
	long long c[101][101], s;
	int i, j, k;
	int n, m, l;

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < m; k++) {
				s += a[i][k] * b[k][j];
			}
			c[i][j] = s;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%lld", c[i][0]);
		for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   int a,b,c;
   cin>>a>>b>>c;
   int x=c/(7*a+b);
   int y=c%(7*a+b);
   int t=7;
   for(int i=0;i<=7;i++){
       if(i*a>=y){
           t=i;
           break;
       }
   }
   cout<<t+7*x<<endl;
  return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

template<typename T, size_t N> istream & operator>>(istream & s, array<T, N> & a) { RF(e, a) { s >> e; } return s; }
template<typename T, size_t N> ostream & operator<<(ostream & s, array<T, N> const & a) {
	inc(i, SI(a)) { s << (i == 0 ? "" : " ") << a[i]; }
	return s;
}

int main() {
	IN(int, A, B, m);
	vector<int> a(A), b(B);
	vector<array<int, 3>> c(m);
	cin >> a >> b >> c;
	
	int mia = 1e9, mib = 1e9;
	inc(i, A) { setmin(mia, a[i]); }
	inc(i, B) { setmin(mib, b[i]); }
	int ans = mia + mib;
	RF(e, c) {
		int x = e[0] - 1;
		int y = e[1] - 1;
		setmin(ans, a[x] + b[y] - e[2]);
	}
	OUT(ans);
}


Measured memory_bytes: 2176
/*
 * ALDS1_2_D.cpp
 *
 *  Created on: Apr 25, 2018
 *      Author: 13743
 */

#include<iostream>

using namespace std;

int cnt = 0;

void insertionSort(int* a, int n, int g) {
	for(int i=g; i<n; i++) {
		int v = a[i];
		int j = i - g;
		while(j >= 0 && a[j] > v) {
			a[j+g] = a[j];
			j = j - g;
			cnt++;
		}
		a[j+g] = v;
	}
}

int main() {
	int n;
	cin >> n;
	int a[1000000];
	for(int i=0; i<n; i++) {
		cin >> a[i];
	}
	int g[100];
	int m=0;
	int gg = 1;
	while(m < 100 && gg <= n) {
		g[m] = gg;
		m++;
		gg = 3*gg + 1;
	}
	
	for(int i=0; i<m; i++) {
		insertionSort(a, n, g[m-1-i]);
	}
	
	cout << m << endl;
	cout << g[m-1];
	for(int i=1; i<m; i++) {
		cout << " " << g[m-1-i];
	}
	cout << endl;
	cout << cnt << endl;
	for(int i=0; i<n; i++) {
		cout << a[i] << endl;
	}
}





Measured memory_bytes: 6908
#include<bits/stdc++.h>
    using namespace std;
    using ll = long long;
    #define pb push_back
    #define eb emplace_back
    #define mp make_pair
    #define ff first
    #define ss second

    void io(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        #ifdef LOCAL
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
    }
    ll ans;
    int x;
    const int N = 2e5 + 5;
    int main() {
        io();
        string s;
        int n, p;
        
      	cin >> s;
      	n = s.size()  ;	
      	map <int, int> f;
      	p = 2019;
        if(p == 2) {
            for(int i = 0; i < n; i++) {
                if((s[i] - '0') % 2 == 0) {
                    ans += (i + 1);
                }
            }
            cout << ans;
        }
        else if(p == 5) {
            for(int i = 0; i < n; i++) {
                if(s[i] == '5' || s[i] == '0') {
                    ans += (i + 1);
                }
            }
            cout << ans;
        }
        else {
            reverse(s.begin(), s.end());
            int num = 0;
            f[0] = 1;
            int t = 1;
            for(int i = 0; i < n; i++) {
                num = num + t * (s[i] - '0');
                t = t * 10 % p;
                num = num % p;
                f[num]++;


            }          

            for(auto it : f) {

                    ans += ((1LL * it.second * (it.second - 1)) / 2);

            }
            cout << ans;
        }



    }


Measured memory_bytes: 3780
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int A, B;
	cin >> A >> B;
	int ans = -1;
	if (1 <= A && A <= 9 && 1 <= B && B <= 9)
	{
		ans = A * B;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
if n<3:
  print(0)
  exit()

count = 1
for num in range(2,n):
  
  lest = n - 3*num
  if (lest < 0):
    break
  count += combinations_count(lest+num-1, lest)
  
print(count%(10**9+7))

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

int main() {
  int n;
  std::cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  for (int i = n - 1; i > 0; i--) {
    std::cout << a[i] << " ";
  }
  std::cout << a[0] << std::endl;
}


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

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


int main() {
	string s;
	while (getline(cin, s), (s != ".")) {
		stack<char> st;
        st.push('a');
		bool ok = true;
		for (char c : s) {
			if (c == '(' || c == '['){ st.push(c); }
			if (c == ')'){ if(st.top() == '(') st.pop(); else ok = false; }
			if (c == ']'){ if(st.top() == '[') st.pop(); else ok = false; }
		}
		cout << (ok && st.size() == 1 ? "yes" : "no") << endl;
	}
}

Measured memory_bytes: 3204
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 25005;
const int MAXK = 405;
const ll MOD = 1000000007;

int n,K,m,L,R;
int a[MAXN];

ll ans;
ll f[MAXN][MAXK];
ll sum[MAXN][MAXK];

bool vis[MAXK];

int main()
{
	scanf("%d%d%d",&n,&K,&m);
	for (int i = 1;i <= m;i++)
		scanf("%d",&a[i]);
	bool ok = 0;
	for (int i = 1;i + K - 1 <= m;i++)
	{
		for (int j = i;j <= i + K - 1;j++)
			vis[a[j]] = 1;
		bool flag = 1;
		for (int j = 1;j <= K;j++)
			if (!vis[j])
				flag = 0;
		if (flag)
			ok = 1;
		memset(vis,0,sizeof(vis));
	}
	L = m;
	for (int i = 1;i <= m;i++)
	{
		if (vis[a[i]])
		{
			L = i - 1;
			break;
		}
		vis[a[i]] = 1;
	}
	memset(vis,0,sizeof(vis));
	R = 1;
	for (int i = m;i >= 1;i--)
	{
		if (vis[a[i]])
		{
			R = i + 1;
			break;
		}
		vis[a[i]] = 1;
	}
	for (int i = 1;i < K;i++)
	{
		f[0][i] = 1;
		sum[0][i] = (sum[0][i - 1] + f[0][i]) % MOD;
	}
	for (int i = 1;i <= n;i++)
		for (int j = 1;j < K;j++)
		{
			f[i][j] = sum[i - 1][j];
			if (j < K - 1)
				(f[i][j] += (K - j) * f[i - 1][j + 1]) %= MOD;
			sum[i][j] = (sum[i][j - 1] + f[i][j]) % MOD;
		}
	for (int i = 1;!ok && i + m - 1 <= n;i++)
	{
		if (R != 1)
		{
			(ans -= f[i - 1][L] * f[n - (i + m - 1)][m - R + 1]) %= MOD;
			continue;
		}
		if (i == 1)
			(ans -= f[n - (i + m - 1)][m]) %= MOD;
		int cnt = m;
		ll v = 1;
		for (int j = i - 1;j >= 1;j--)
		{
			(ans -= v * f[n - (i + m - 1)][i + m - 1 - j] % MOD * sum[j - 1][i + m - 1 - j]) %= MOD;
			(v *= K - cnt) %= MOD;
			if (j == 1)
				(ans -= v * f[n - (i + m - 1)][i + m - 1]) %= MOD;
			cnt++;
			if (cnt == K)
				break;
		}
	}
	ll v = 1;
	for (int i = 1;i <= n - m;i++)
		(v *= K) %= MOD;
	(ans += v * (n - m + 1)) %= MOD;
	printf("%lld\n",(ans + MOD) % MOD);
	return 0;
}

Measured memory_bytes: 158592
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;



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

  int even = 0;
  int odd = 0;

  int a;

  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0)
      even++;
    else
      odd++;
  }

  if (odd % 2 == 0) {
    printf("YES\n");
    return 0;
  }
  else if (odd == 1 && even == 0) {
    printf("YES\n");
    return 0;
  }
  else {
    printf("NO\n");
    return 0;
  }
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}

void solve()
{
 string s;
 cin >> s;

 for(int i=0;i<sz(s);i++)
 {
    cout<<"x";
 }

}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3644
#include "bits/stdc++.h"

using namespace std;

int main()
{
        string s, t;
        int counter = 0;
        cin >> s >> t;
        for (int i = 0; i < s.size(); i++)
        {
                if (s[i] != t[i])
                {
                        counter++;
                }
        }
        cout << counter << endl;

        return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
ll MOD = 1e9+7;
ll gcd(ll a,ll b){
  if(a<b) swap(a,b);
  if(a%b==0) return b;
  else return gcd(b,a%b);
}
int main() {
  ll n;
  cin >> n;
  vl a(n);
  REP(i,n) cin >> a[i];
  vl modinv(1e6+1);
  modinv[1] = 1;
  FOR(i,2,modinv.size()){
    modinv[i] = modinv[MOD%i] * (MOD - MOD/i) % MOD;
  }

  vl primes;
  vector<bool> isPrime(1e6+1,true);
  isPrime[0] = false;
  isPrime[1] = false;
  FOR(i,2,1e6+1){
    if(!isPrime[i]) continue;
    for(ll j = i*2; j<=1e6; j+=i){
      isPrime[j] = false;
    }
  }
  REP(i,1e6+1) if(isPrime[i]) primes.push_back(i);
  vl lcd(primes.size(),0);
  REP(i,n){
    ll m = a[i];
    if(m==1) continue;
    {
      ll lw = 0;
      ll up = primes.size();
      while(abs(lw-up)>1){
        ll mid = (lw+up)/2;
        if(primes[mid]<=m) lw = mid;
        else up = mid;
      }
      if(primes[lw]==m){
        CHMAX(lcd[lw],1ll);
        continue;
      }
    }
    REP(j,primes.size()){
      if(m==1) continue;
      ll cnt = 0;
      while(m%primes[j]==0){
        cnt++;
        m /= primes[j];
      }
      CHMAX(lcd[j],cnt);
    }
  }

  ll ld = 1;
  REP(i,primes.size()){
    REP(j,lcd[i]){
      ld *= primes[i];
      ld %= MOD;
    }
  }
  ll ans = 0;
  REP(i,n){
    ll bi = (ld * modinv[a[i]]) % MOD;
    ans += bi;
    ans %= MOD;
  }

  
  //cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9716
#include <iostream>

using namespace std;

int main(){
  long long n, k;
  long long total = 0;
  cin >> n >> k;
  if (k==0) {
    cout << n*n << endl;
    return(0);
  }
  for (int b=k+1;b<=n;b++) {
    int r = n%b >= k?n%b-k+1:0;
    total += (n/b)*(b-k) + r;
    //    cout << b << "\t" << (n/b)*(b-k) << "\t" << r << endl;
  }
  cout << total << endl;
  return(0);
}


Measured memory_bytes: 256
N,K=(input().split())
N,K=int(N),int(K)
seq=list(input().split())
seq=[int(x) for x in seq]
cou=0
C=0
inc=0
for i in range(len(seq)):
    for j in range(i+1,len(seq)):
        if seq[i]>seq[j]: cou+=1
for i in range(len(seq)):
    for j in range(len(seq)):
        if seq[i]>seq[j]: inc+=1
C=(K*(K-1)//2)*inc+K*cou
print(C%(10**9+7))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll h,w,ans=0;
int main()
{
    cin>>h>>w;
    if(h==1||w==1){
        cout<<1;
    }
    else{
        cout<<(w*h+1)/2;
    }
    return 0;
}

Measured memory_bytes: 256
function main(input){
	input = input.trim();
	var list = input.split(" ");
	var jHari = parseInt(list[0]);
	var fHari = parseInt(list[1]);
	var ji = parseInt(list[2]);
	var fun = parseInt(list[3]);

	function deg(deg){
		return(deg*Math.PI/180);
	}
	var posJ = [Math.cos(deg(ji*30+fun*0.5))*jHari, Math.sin(deg(ji*30+fun*0.5))*jHari];
	var posF = [Math.cos(deg(fun*6))*fHari, Math.sin(deg(fun*6))*fHari];
	function kyori(ax,ay,bx,by){
		return(Math.sqrt((ax-bx)**2+(ay-by)**2));
	}
	var answer = kyori(posJ[0],posJ[1],posF[0],posF[1]);
	console.log(answer.toString());
}
main(require("fs").readFileSync("/dev/stdin","utf8"));

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define vc vector<char>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define all(x) (x).begin(),(x).end()
#define get_bit(x, k) ((x >> k) & 1)
// ---------------------------------

void MAIN() {
  int n; cin >> n;
  string s;
  cin >> s;
  int r = 0;
  for (auto &i : s) {
    if (i == 'R') r++;
  }
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (i < r && s[i] == 'R') c++;
  }
  cout << r - c << '\n';
}

signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

using namespace std;

#define all(a) a.begin(), a.end()
#define pi acos(-1)
#define eps 1e-6
#define inf 1e18

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
const int dy[8] = {-1, 0, 1, -1, 1, 0, 1, -1};
const int maxn = 3001;
const int mod = 1e9 + 7;
const int maxa = 2 * 1e5;

int maxs(int &a, int b) { return a = max(a, b);}
int mins(int &a, int b) { return a = min(a, b);}
int mul(int a, int b) { return a * 1LL * b % mod;}
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b;}
int sub(int a, int b) { return a >= b ? a - b : a - b + mod;}
int pow(int a, int k)
{
    int res = 1;
    while (k)
    {
        if (k % 2) res = mul(res, a);
        a = mul(a, a);
        k /= 2;
    }

    return res;
}

int inv(int a)
{
    return pow(a, mod - 2);
}

ll dp[maxn][maxn], A[maxn], n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> A[i];

    for (int l = n - 1; l >= 0; --l)
        for (int r = l; r < n; ++r)
            dp[l][r] = l == r ? A[l] : max(A[l] - dp[l + 1][r], A[r] - dp[l][r - 1]);

    cout << dp[0][n - 1];
}


Measured memory_bytes: 70016
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; // 削除する対象
  Node *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}


Measured memory_bytes: 20488
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Y;
  int A_sum, B_sum;
  cin >> N >> Y;
  for (int i = 0; i<=N; i++) {
    A_sum = 10000 * i;
    int substract = Y - A_sum;
    int N1 = N - i;
    if (substract < 0) {
      continue;
    }
    for (int j = 0; j<=N; j++) {
      B_sum = 5000 * j;
      int substract2 = substract - B_sum;
      int division = substract2 / 1000;
      int N2 = N1 - j;
      if (substract2 < 0 || i + j > N) {
      continue;
      }
      if ( substract2 % 1000 == 0 && division == N2) {
        cout << i << " " << j << " " << division << endl;
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

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

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N+1];
  rep(i, N)
    cin >> A[i];
  //入力終わり

  //配列にA[i]-iを入れていく
  int sub[N];
  rep(i, N)
    sub[i] = A[i]-i;

  sort(sub+1, sub+N+1 );

  //sub_absの中央値に設定すれば最適
  int b = sub[N/2 + 1];

  //|A[i]-(b+i)|
  long long ans = 0;
  rep(i, N)
    ans += abs(A[i]-(b+i ) );
    
  //解答
  cout << ans << endl;
  
  return 0;
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

vector<vll> seg;
ll n;

void init(ll N) {
    ll n_ = 1;
    while(n_ < N) {
        n_ *= 2;
    }
    n = n_;
    for(ll i = 0; i < n * 2 - 1; i++) {
        seg.push_back(vll(26, 0));
    }
}

void update(ll idx, char c, char p) {
    idx += n - 1;
    if(p != '.') {
        seg[idx][p - 'a']--;
    }
    seg[idx][c - 'a']++;
    while(idx > 0) {
        idx = (idx - 1) / 2;
        if(p != '.') {
            seg[idx][p - 'a']--;
        }
        seg[idx][c - 'a']++;
    }
}

vll query_sub(ll a, ll b, ll k, ll l, ll r) {
    if(r <= a || b <= l) {
        return vll(26, 0);
    } else if(a <= l && r <= b) {
        return seg[k];
    } else {
        vll vl = query_sub(a, b, k * 2 + 1, l, (r + l) / 2);
        vll vr = query_sub(a, b, k * 2 + 2, (r + l) / 2, r);
        for(ll i = 0; i < 26; i++) {
            vl[i] += vr[i];
        }
        return vl;
    }
}
ll query(ll a, ll b) {
    vll result = query_sub(a, b, 0, 0, n);
    ll n_c = 0;
    ll i;
    for(i = 0; i < 26; i++) {
        if(result[i] > 0)
            n_c++;
    }
    return n_c;
}

int main() {
    ll i;
    ll N, Q;
    string S;
    cin >> N >> S >> Q;
    init(N);
    for(i = 0; i < N; i++) {
        update(i, S[i], '.');
    }
    for(i = 0; i < Q; i++) {
        ll q;
        cin >> q;
        if(q == 1) {
            ll idx;
            char c;
            cin >> idx >> c;
            idx--;
            update(idx, c, S[idx]);
            S[idx] = c;
        } else {
            ll le, ri;
            cin >> le >> ri;
            le--;
            ri--;
            ll ans = query(le, ri + 1);
            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 254700
char s[20];c;
main(i){
	gets(s);
	for(;i<strlen(s);i++)c+=s[i]<'a'?2-(s[i]=='C'):0;
	puts(s[0]!='A'||c!=1||s[1]<'a'||s[strlen(s)-1]<'a'?"WA":"AC");
}

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

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define pqll priority_queue<ll>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) ll a[n+f];for(int hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mapp map<ll,ll>
#define mem(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
#define inf LLONG_MAX


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

	int h,w,k,ans=0;
	cin>>h>>w>>k;
	string s[h];
	for(int i=0;i<h;i++)
		cin>>s[i];
	for(int m1=0;m1<(1<<h);m1++)
	{
		for(int m2=0;m2<(1<<w);m2++)
		{
			int temp=0;
			for(int i=0;i<h;i++)
				for(int j=0;j<w;j++)
					if(((m1&(1<<i))==0)&&((m2&(1<<j))==0)&&s[i][j]=='#')
						++temp;
			if(temp==k)
				ans++;
		}
	}
	cout<<ans;
	return 0;
}


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


int main(){


    int n, q, l, r, i;

    string s;

    vector<int> a;


    cin >> n >> q >> s;


    vector<int> sv(n + 1);


    sv.at(0) = 0;

    sv.at(1) = 0;


    for( i = 1 ; i < n ; i = i + 1 ){

         if( s.at(i) == 'C' && s.at(i - 1) == 'A' ) sv.at(i + 1) = sv.at(i) + 1;

         else sv.at(i + 1) = sv.at(i);

         }


    for( i = 0 ; i < q ; i = i + 1 ){

         cin >> l >> r;

         a.push_back( sv.at(r) - sv.at(l) );

         }


    for( i = 0 ; i < q ; i = i + 1 ){

         cout << a.at(i) << endl;

         }


    return 0;

    }


Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5+10;
int n, a[MAXN];

int main() {
    scanf("%d", &n);
    for(int i=0;i<n;i++) {
        scanf("%d", &a[i]); 
    }

    int ans = 1;
    int trend = 0;

    for(int i=1;i<n;i++) {
        if(a[i] == a[i-1]) continue;
        if(trend == 1 && a[i]>a[i-1]) {
            trend = 0; ans++;
        } else if(trend == -1 && a[i]<a[i-1]) {
            trend = 0; ans++;
        } else trend = (a[i]<a[i-1]) ? 1:-1;

    }

    printf("%d\n", ans);
}


Measured memory_bytes: 640
N,W=map(int,input().split())
dp=[[-1 for i in range(W+1)] for i in range(N)]
wv=[]
for _ in range(N):
    w,v=map(int,input().split())
    wv.append([w,v])
dp[0][0]=0
dp[0][wv[0][0]]=wv[0][1]
for i in range(N-1):
    for j in range(W):
        if dp[i][j]!=-1:
            dp[i+1][j]=max(dp[i+1][j],dp[i][j])
            if j+wv[i+1][0]<=W:
                dp[i+1][j+wv[i+1][0]]=\
                    max(dp[i][j]+wv[i+1][1],dp[i+1][j+wv[i+1][0]])
ans=0
for i in range(W+1):
    if dp[N-1][i]>ans:
        ans=dp[N-1][i]
print(ans)

Measured memory_bytes: 171656
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define F(i,a,b) for(int i= (int)(a); i<(int)(b);i++)
#define FI(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define what_is(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pii pair<int,int>
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
const int N = 1e6+7 ;
string s ;

int main(){fast ;
	int n,k ;
	cin >> k >> n ;
	vi a(n) ;
	for(int i = 0 ; i < n ; i++)
		cin >> a[i] ;	
	sort(all(a)) ;
	vi b ;
	for(int i = 1 ; i < n ; i++){
		b.pb(a[i]-a[i-1]) ;
	}
	sort(all(b)) ;
	int sm = 0 ;
	for(int i = 0 ; i < n-k ; i++){
		sm += b[i] ;
	}
		cout << sm << endl ;
}




Measured memory_bytes: 1276
N,H,W=map(int,input().split())
table=[[] for i in range(N)]
for i in range(N):
    a,b=map(int,input().split())
    table[i].append(a)
    table[i].append(b)
c=0
for i in range(N):
    if table[i][0]>=H and  table[i][1]>=W:
        c+=1
print(c)


Measured memory_bytes: 3188
n, y=map(int, input().split())
flag=False
for i in range(n+1):
    for j in range(0, n-i+1):
        if y==10000*i+5000*j+1000*(n-i-j):
                print("{} {} {}".format(i, j, n-i-j))
                flag=True
                break
    if flag:
            break

if not flag:
    print("-1 -1 -1")


Measured memory_bytes: 42732
def main():
    n = int(input())
    a = []
    sum = 0             #longの気持ち
    ans = 0             #long long の気持ち
    mod = 1_000_000_000 + 7
    x = list(map(int, input().split()))
    for i in range(n):
        sum += x[i]           
        a.append(x[i])
    
    sum % mod
    
    for i in range(n):
        sum -= a[i]
        if sum < 0:
            sum += mod
        ans += sum * a[i]
        ans %= mod
    print(ans)

if __name__ == "__main__":
    main()

    

Measured memory_bytes: 30956
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def main():
	n,m=map(int,input().split())
	
	li=[0]*(n+1)
	
	wa=0
	
	for i in range(m):
		p,s=input().split()
		p=int(p)
		s=s.rstrip().decode('utf-8')
		
		if li[p]==-1:
			continue
		if s=="WA":
			li[p]+=1
		else:
			wa+=li[p]
			li[p]=-1
	
	print(li.count(-1),wa)
	
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 41196
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> cnt(n);
    for(int i=1;i<n;i++){
        if(s[i-1]=='A' && s[i]=='C'){
            cnt[i]++;
        }
    }
    for(int i=1;i<n;i++){
        cnt[i] += cnt[i-1];
    }

    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >> r;
        l--,r--;
        cout << cnt[r]-cnt[l] << endl;
    }
}


Measured memory_bytes: 1408
#include<stdio.h>

int main() {
   int n,k,i,j,temp,sum;
   int l[50];
   
   sum = 0;

   scanf("%d %d",&n,&k);

   for(i = 0; i < n; i++){
       scanf("%d",&l[i]);
   }
  
   for(i = 0; i < n; i++){
       for(j = n-1; j > i; j--){
     	   if(l[i] < l[j]){
                 temp = l[j];
		 l[j] = l[i];
		 l[i] = temp;
           }
       }
   }
   
   
   for(i = 0; i < k ; i++){ 
       sum += l[i];
   }  
   
   printf("%d \n",sum);
     
   return(0);       
}

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

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var line = System.Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        var a = line[0];
        var b = line[1];

        var ans = a > 9 || b > 9 ? -1 : a * b;
        System.Console.WriteLine(ans);
    }
}



Measured memory_bytes: 13268
#include <iostream>
#include <cstring>
#include <cmath>
#include <climits>

#define ll long long

using namespace std;

int n, x;
int num[6];
int main() {

    for(int i=1;i<=5;i++) {
        
        cin>>num[i];
        if(num[i] ==0 ) {
            
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3552
a, b = list(map(int, input().split()))
if a <= 0 <= b:  ### a と b の間に0を含む時
    print("Zero")
elif 0 < a <= b: ### a と b が正の場合
    print("Positive")
elif a <= b < 0: ### a と b が負の場合
    ### a と b の間に数字が偶数個なら正、奇数個なら負
    if (b - a + 1) % 2 == 0:
        print("Positive")
    else:
        print("Negative")

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-


a,b,c,x,y = map(int,input().split())

minprice = float("inf")

for i in range(1000001):
    buya = max(0,x - int(i / 2))
    buyb = max(0,y - int(i / 2))
    buyc = i
    price = buya * a + buyb * b + buyc * c
    if price < minprice:
        minprice = price

print(minprice)


Measured memory_bytes: 3060
def main():
    N, Y = map(int, input().split())
    m = 10000
    ft = 5000
    t = 1000
    for i in range(N+1):
        for j in range(N-i+1):
            k = N - i - j
            if m*i + ft*j + t*k == Y and i + j + k == N:
                print(str(i) + ' ' + str(j) + ' ' + str(k))
                return
    print('-1 -1 -1')

main()  

Measured memory_bytes: 9100
package main
import (
    "fmt"
    "bufio"
    "os"
    "sort"
    "container/heap"
)
var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

type kek struct{
    k int
    l int64
}
type IntHeap []int64

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *IntHeap) Push(x interface{}) {
    *h = append(*h, x.(int64))
}
func (h *IntHeap) Pop() interface{} {
    old := *h
    n := len(old)
    x := old[n-1]
    *h = old[0 : n-1]
    return x
}
func solve(a []kek) int64 {
    var ans int64 = 0
    sort.Slice(a, func(i, j int) bool {
        return a[i].k < a[j].k
    })
    var na = len(a)
    h := &IntHeap{}
    heap.Init(h)
    for i := 0; i < na; i++ {
        heap.Push(h, a[i].l)
        ans += int64(a[i].l)
        if h.Len() > a[i].k{
            ans -= heap.Pop(h).(int64)
        }
    }
    return ans
}
func main() {
    defer writer.Flush()
    var t,n int
    scanf("%d\n", &t)
    for ;t>0;t-- {
        scanf("%d\n", &n)
        var a []kek
        var b []kek
        var ans int64 = 0
        for i := 0; i < n; i++ {
            var k int
            var l,r int64
            scanf("%d %d %d\n", &k,&l,&r)
            if l>=r{
                ans += r
                a=append(a,kek{k,l-r})
            } else {
                ans += l
                b=append(b,kek{n-k,r-l})
            }
        }
        ans += solve(a)
        ans += solve(b)
        printf("%d\n",ans)
    }
}

Measured memory_bytes: 14492
from fractions import gcd
from math import factorial


def nCr(n, r):
    return factorial(n) // factorial(r) // factorial(n - r)


def lcm(x, y):
    return (x * y) // gcd(x, y)


def prime_numbers(n):
    if n < 2:
        return [1]
    primes = []
    for p in range(2, int(pow(n, 0.5)) + 1):
        if p * p > n:
            break
        while n % p == 0:
            primes.append(p)
            n //= p
    if n > 1:
        primes.append(n)
    return primes


def m():
    a, b = map(int, input().split())
    x = gcd(a, b)
    p = prime_numbers(x)
    p.append(1)

    return len((set(p)))


print(m())


Measured memory_bytes: 5332
#include<iostream>
		#include<cmath>
		#include<algorithm>
		#include<string>


		using namespace std;

		int main() {
			int n;
			cin >> n;
			int p[10000];
			for (int i = 0;i < n;i++) {
				cin >> p[i];
			}
			int i = 0;
			int cnt = 0;
			int id = 0;
			for (i = 0;i < n;i++) {
				if (cnt < p[i]) {
					cnt = p[i];
					id = i;
				}
			}
			int ans = 0;
			for (i = 0;i < n;i++) {

				ans += p[i];
				if (i == id) {
					ans -= p[id]/2;
				}
			}
			cout << ans << endl;
		}

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

int main() {
	ll n,k; cin>>n>>k;
	vector<ll> x(n),y(n);
	for (ll i=0; i<n; i++)
		cin>>x[i]>>y[i];

	ll ans=~(1LL<<63);
	for (ll a=0; a<n; a++) {
		for (ll b=a; b<n; b++) {
			for (ll c=b; c<n; c++) {
				for (ll d=c; d<n; d++) {
					ll right = max({x[a],x[b],x[c],x[d]});
					ll left = min({x[a],x[b],x[c],x[d]});
					ll top = max({y[a],y[b],y[c],y[d]});
					ll bot = min({y[a],y[b],y[c],y[d]});
					ll area = abs((top-bot) * (right-left));
					ll contains=0;
					for (ll m=0; m<n; m++)
						if (x[m]>=left and x[m]<=right and y[m]>=bot and y[m]<=top)
							contains++;
					if (contains>=k and area<ans)
						ans=area;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256