akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>

using namespace std;

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

    string s;
    cin >> s;

    int count = 0;
    for(int i = 0; i <= 999; ++i)
    {
        char master[4];
        sprintf(master, "%03d", i);
        int pi = 0;
        for(int j = 0; j < s.size(); ++j)
        {
            if(s[j] == master[pi])
            {
                pi++;
                if(pi == 3)
                {
                    break;
                }
            }
        }
        if(pi == 3)
        {
            count++;
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,a[3];
main()
{
    cin>>n;int M=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(M<a[i])M=a[i];
    }
    for(int i=1;i<=M;i++)
    {
        bool f=1;
        for(int j=0;j<n;j++)f&=a[j]%i<1;
        if(f)cout<<i<<endl;
    }
}


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

int main(){
    bool qwerty=1;
    while(qwerty){
        int m,f,r;
        cin >> m >> f >> r;
        if (m==-1 && f==-1 && r==-1) {qwerty=0;}
        else if (m==-1 || f==-1) {cout << "F" << endl;}
        else if (m+f>=80) {cout << "A" << endl;}
        else if (m+f>=65) {cout << "B" << endl;}
        else if (m+f>=50) {cout << "C" << endl;}
        else if (m+f>=30){
            if (r>=50) {cout << "C" << endl;}
            else {cout << "D" << endl;}
        }
        else {cout << "F" << endl;}
    }
}


Measured memory_bytes: 3096
k = int(input())
a = list(map(int, input().split()))

def sim(num):
    for g in a:
        num = g * (num//g)
    return num

l=0
r=100+k*max(a)
while r-l>1:
    mid=(l+r)//2

    if sim(mid) > 2:
        r=mid
    else:
        l=mid
ans_max=l

l=0
r=100+k*max(a)
while r-l>1:
    mid=(l+r)//2

    if sim(mid) < 2:
        l=mid
    else:
        r=mid
ans_min=r

if ans_min > ans_max:
    print(-1)
else:
    print(ans_min,ans_max)

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

int main() {
  int n;
  cin >> n;
  map<int, int> mp;
  rep(i,n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  vector<P> b;
  for (auto e : mp) b.emplace_back(make_pair(e.first, e.second));
  sort(b.begin(), b.end(), greater<P>());
  int m = b.size();
  ll res = 0;
  for (int i = 0; i < m; i++) {
    int cnt = b[i].second;
    ll h = b[i].first;
    if (cnt >= 4) {
      cout << h * h << endl;
      return 0;
    }
    if (cnt >= 2) {
      for (int j = i + 1; j < m; j++) {
        if (b[j].second >= 2) {
          cout << h * (ll)b[j].first << endl;
          return 0;
        }
      }
      cout << 0 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 6136
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////
	

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n, a, b;
	cin >> n >> a >> b;
	if(n * a < b){
		cout << n * a << endl;
	}
	else cout << b << '\n';
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,K;
  cin>>K>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
  cin>>A.at(i);
  
  }
  vector<int> x(N);
    for(int i=0;i<N-1;i++){
  x.at(i)=A.at(i+1)-A.at(i);
  }
  
  x.at(N-1)=A.at(0)+(K-A.at(N-1));
  sort(x.begin(),x.end());
  cout<<K-x.at(N-1)<<endl;

}

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

int main() {
  int n;
  cin >> n;
  for (int i = 1; i < 10; i++) {
    if (n % i == 0 && n / i < 10) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/priority_queue.hpp>
#define priority_queue __gnu_pbds::priority_queue
typedef long long LL;
typedef long double LD;
typedef unsigned int ui;
typedef unsigned long long ul;
#define ri register int
#define pb push_back
#define fi first
#define se second
#define mid ((l + r) >> 1)
#define ls (i << 1)
#define rs (i << 1 | 1)
#define enum(i, j, k) for(int i = j; i <= k; i ++)
#define FO(x) { freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout); }
using namespace std;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<int, LL> pil;
typedef pair<LL, int> pli;
typedef vector<int> vi;
#define ae(x) for(node *p = h[x]; p; p = p->nxt)
#define G \
	struct node { int v; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v) { e[++z].v = v; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v) { adde(u, v); adde(v, u); }
#define W \
	struct node { int v, w; node *nxt; } e[maxm], *h[maxn]; int z;\
	void adde(int u, int v, int w) { e[++z].v = v; e[z].w = w; e[z].nxt = h[u]; h[u] = &e[z]; }\
	void addrev(int u, int v, int w) { adde(u, v, w); adde(v, u, w); }
inline int _() // ret >= 0
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	do { ret = ret * 10 + ch - '0'; ch = getchar(); } while('0' <= ch && ch <= '9');
	return ret;
}
inline void _(int x) // x >= 0
{
	if(x < 10) { putchar(x + '0'); return ; }
	_(x / 10); putchar(x % 10 + '0');
}
void What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(16);
}
/* Default Code Ends Here. */

void no()
{
	cout << "No";
}
void yes()
{
	cout << "Yes";
}

bool f[50];

int main()
{
	What_are_you_doing_at_the_end_of_the_world_Are_you_busy_Can_you_save_us();
	
	string s;
	cin >> s;
	for(char c : s)
	{
		f[c - 'A'] = true;
	}
	if(f['N' - 'A'] ^ f['S' - 'A'] || f['E' - 'A'] ^ f['W' - 'A'])
		no();
	else
		yes();
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int h, w, k; cin >> h >> w >> k;
    vector<string> s(h);
    pair<int, int> start;
    for (int i = 0; i < h; i++) {
        cin >> s[i];
        for (int j = 0; j < w; j++) {
            if (s[i][j] == 'S') start = {i,j};
        }
    }
    const int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};
    vector<vector<int>> dist(h, vector<int>(w, -1));
    queue<pair<int, int>> que;
    que.push(start);
    dist[start.first][start.second] = 0;
    constexpr int INF = 1e9 + 6;
    int ans = (min({start.first, start.second, h - start.first - 1, w - start.second - 1}) + k - 1) / k + 1;
    while (!que.empty()) {
        auto p = que.front(); que.pop();
        int x = p.first, y = p.second;
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny < w && s[nx][ny] == '.' && dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y] + 1;
                if (dist[nx][ny] < k) que.push({nx,ny});
                ans = min(ans, (min({nx, ny, h - nx - 1, w - ny - 1}) + k - 1) / k + 1);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
print(3*N*N)



Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define abs(n) ( (n) < 0 ) ? -(n) : (n)

int main(void){

  //入力
  string s;
  cin >> s;
  
  //奇数だけの文字列
  string ans = "";
  for(int i = 0; i < s.size(); i = i + 2){
    ans += s[i];
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
a = []
for i in range(X):
    for j in range(Y):
        a.append(A[i] + B[j])
a.sort()
b = []
for i in range(min(3000, X * Y)):
    b.append(a[- i - 1])
c = []
for i in range(len(b)):
    for j in range(Z):
        c.append(b[i] + C[j])
c.sort()
for i in range(K):
    print(c[- i - 1])

Measured memory_bytes: 148160
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	A, B := sc.nextInt(), sc.nextInt()
	if A > 8 || B > 8 {
		fmt.Fprintln(wtr, ":(")
	} else {
		fmt.Fprintln(wtr, "Yay!")
	}

	wtr.Flush()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int                 long long
#define FF(i,a,b)           for(int i=a;i<b;i++)
#define BF(i,a,b)           for(int i=a;i>=b;i--)
#define vi                  vector<int>
#define MAP                 map<int,int>
#define pb                  push_back
#define MP                  make_pair
#define F                   first
#define S                   second
#define pi                  pair<int,int>
#define all(v)              v.begin(),v.end()
#define PIE                 3.1415926535897932384626433832795
#define print0(a)           cout<<a<<"\n"
#define print1(a)           cout<<a<<' '
#define print2(a,b)         cout<<a<<" "<<b<<" ";
#define print3(a,b,c)       cout<<a<<" "<<b<<" "<<c<<" ";
#define print4(a,b,c,d)     cout<<a<<" "<<b<<" "<<c<<" "<<d<<" ";
#define FastIO              ios::sync_with_stdio(0); cin.tie(0);cout.tie(0)
/**************************************************************************************/
                       /*Global Variables*/
const int mod = 1e9+7;
const int N = 2e5+10;
const int inf = 1e18;
vector<int> g[N];

/**************************************************************************************/
template <typename A>istream& operator>>(istream& input,vector<A>& x) {for(auto& i:x)input>>i;return input;}
template<typename A>ostream& operator<<(ostream& output,vector<A>& x) {for(auto& i:x)output<<i<<' ';return output;}
int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
int Power(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res*=a;
        a*=a;
        b>>=1;
    }
    return res;
}
signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    FastIO;
    int T=1;
    //cin>>T;
    while(T--)
    {
       int x;
       cin>>x;
       for(int i=-120;i<120;i++)
       {
           for(int j=120;j>=-120;j--)
           {
               if(((i*i*i*i*i)-(j*j*j*j*j))==x)
               {
                   cout<<i<<" "<<j<<"\n";
                   return 0;
               }
           }
       }

       
    }

}
/*
|| Do what you can with all you have,wherever you are. ||

|| Knowing is not enough, we must apply. Wishing is not enough, we must do. ||

|| A goal is a dream with deadline. ||

|| Whether you think you can or you think you can't, you're right. ||
*/



Measured memory_bytes: 8336
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int n;
    cin>>n;
    int p[n];
    rep(i,n)cin>>p[i];
    int ans=0;

    rep(i,n){
        if(i-1<0){
            continue;
        }
        else if(i+1>n-1){
            continue;
        }
        else{
            int a,b;
            a = max(p[i+1],p[i-1]);
            b = min(p[i+1],p[i-1]);
            if(a>p[i] && b<p[i]){
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
typedef pair<int,int> P;
int n,m,hp[100],dp[100001],dp2[100001],inf=1e9;
vector<P> al,one;
int dfs(int h){
	if(dp[h]!=inf) return dp[h];
	rep(i,one.size()){
		int mp=one[i].fs,dam=one[i].sc;
		if(dam>=h) dp[h]=min(dp[h],mp);
		else dp[h]=min(dp[h],dfs(h-dam)+mp);
	}
	return dp[h];
}
int dfs2(int h){
	if(dp2[h]!=inf) return dp2[h];
	rep(i,al.size()){
		int mp=al[i].fs,dam=al[i].sc;
		if(dam>=h) dp2[h]=min(dp2[h],mp);
		else dp2[h]=min(dp2[h],dfs2(h-dam)+mp);
	}
	return dp2[h];
}
int main(){
	while(true){
		cin>>n;
		if(n==0) break;
		al.clear();
		one.clear();
		rep(i,n) cin>>hp[i];
		rep1(i,100000) dp[i]=inf,dp2[i]=inf;
		cin>>m;
		rep(i,m){
			string name,tar;
			int mp,dam;
			cin>>name>>mp>>tar>>dam;
			if(dam==0) continue;
			if(tar[0]=='A') al.pb(P(mp,dam));
			else one.pb(P(mp,dam));
		}
		rep1(i,100000) dfs(i),dfs2(i);
		int ans=inf;
		if(al.size()==0){
			int now=0;
			rep(i,n) now+=dp[hp[i]];
			ans=min(ans,now);
		}else if(one.size()==0){
			int mx=0;
			rep(i,n) mx=max(mx,hp[i]);
			ans=dp2[mx];
		}else{
			rep(damal,100001){
				int now=dp2[damal];
				rep(i,n) if(hp[i]>damal) now+=dp[hp[i]-damal];
				ans=min(ans,now);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1992
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int d[100][100],c[1000][1000];
int cnt[3][50];

signed main(){
	int n,c;scanf("%d%d",&n,&c);
	rep(i,c)rep(j,c)cin>>d[i][j];
	rep(i,n)rep(j,n)cin>>::c[i][j],::c[i][j]--;
	rep(i,n)rep(j,n){
		//~ t[(i+j+2)%3]++;
		cnt[(i+j+2)%3][::c[i][j]]++;
	}
	int Min=INT_MAX;
	rep(i,c)rep(j,c){
		if(i==j)continue;
		rep(k,c){
			if(i==k||j==k)continue;
			int a[]{i,j,k};
			int cnt=0;
			rep(t,3){
				rep(l,c){
					cnt+=d[l][a[t]]*::cnt[t][l];
				}
			}
			Min=min(Min,cnt);
		}
	}
	cout<<Min<<endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
    using namespace  std;
    #define MAXNUM 222222
    #define rep(i,s,t) for(int i=s;i<t;i++)
    typedef long long ll;
    const ll mod=1e9+7;
    void add(ll &a,ll b)
    {
        a+=b;
        if(a>=mod)a-=mod;
    }
    int c[MAXNUM];ll bef[MAXNUM],dp[MAXNUM];
    int main()
    {
        int n;scanf("%d",&n);
        dp[0]=1;
        rep(i,1,n+1)
        {
            scanf("%d",&c[i]);
            dp[i]=dp[i-1];
            if(bef[c[i]]&&bef[c[i]]!=i-1)
                add(dp[i],dp[bef[c[i]]]);
            bef[c[i]]=i;
        }
        printf("%lld\n",dp[n]);
    }

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    int x=a[(n/2)-1];
    int y=a[n/2];
    x=y-x;
    cout << x << "\n";
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

const int INF = INT_MAX/3;

void slidingMinimum(vector<int> &inputList, vector<int> &outputList, int slideSize){
    deque<int> dq;
    for(int i=0;i<inputList.size();i++){
        while(!dq.empty()){
            if (inputList[dq.back()] >= inputList[i]){
                dq.pop_back();
            }else{
                break;
            }
        }
        dq.push_back(i);

        outputList.push_back(inputList[dq.front()]);
        if(dq.front() == i - slideSize +1){
            dq.pop_front();
        }
    }
    return;
}

int knapsackProblemWithLimitations(int W, vector<int> &v, vector<int> &w, vector<int> &m){
    int N = v.size();
    int DP[W+1][N];

    for (int i=0;i<W+1;i++){
        for (int j=0;j<N;j++){
            DP[i][j] = 0;
        }
    }

    for (int i=1;i< min(m[0], W/w[0])+1;i++){
        DP[w[0]*i][0] = v[0] * i;
    }

    for (int j=1;j<N;j++){
        for (int t=0;t<w[j];t++){
            vector<int> b,c;
            for (int k=0;(w[j]*k + t)<W+1;k++){
                b.push_back(DP[w[j]*k+t][j-1] - k*v[j]);
            }

            //??¢??°???????°????????±???????????????§???????±???????????????§??\???
            for (int i=0;i<b.size();i++){
                b[i] = - b[i];
            }
            slidingMinimum(b,c,m[j]+1);
            for (int i=0;i<c.size();i++){
                c[i] = - c[i];
            }
/*
            cout << endl;
            for (int p=0;p<b.size();p++){
                cout << b[p] << " ";
            }
            cout << endl <<endl;

            cout << endl;
            for (int p=0;p<c.size();p++){
                cout << c[p] << " ";
            }
            cout << endl <<endl;
*/
            for(int k=0;k<c.size();k++){
                DP[w[j]*k+t][j] = c[k] + k*v[j];
            }
        }
    }
/*
    cout << endl;
    for (int i=0;i<W+1;i++){
        for (int j=0;j<N;j++){
            cout << DP[i][j] << " ";
        }
        cout << endl;
    }
    cout << endl;
*/
    int S = 0;
    for (int i=0;i<W+1;i++){
        S = max(S, DP[i][N-1]);
    }
    return S;
}

int main(){
    int N, W;
    cin >> N >> W;
    vector<int> v(N);
    vector<int> w(N);
    vector<int> m(N);
    for (int i=0;i<N;i++){
        cin >> v[i] >> w[i] >> m[i];
    }

    cout << knapsackProblemWithLimitations(W, v, w, m) << endl;
    return 0;
}

Measured memory_bytes: 7132
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
#define w1 first
#define w2 second
#define ls (x<<1)
#define rs (x<<1|1)
#define pb push_back
#define mid ((l+r)>>1)
#define SZ(x) ((x).size())
#define All(x) (x).begin(),(x).end()
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)])
template<class T>void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=1ll*x*x%p)if(k&1)res=1ll*res*x%p;return res;}
const int maxn=1e6+5;
int n,q;
int a[maxn],b[maxn],d[maxn];
int main(){
	read(n);read(a[0]);
	rep(i,1,n){
		read(d[i]);
		if(a[i-1]>=d[i])a[i]=a[i-1]-d[i];
		else a[i]=min(a[i-1],d[i]-a[i-1]);
	}
	b[n+1]=1;
	per(i,n,1){
		if(b[i+1]<=d[i]/2)b[i]=b[i+1];
		else b[i]=b[i+1]+d[i];
	}
	read(q);
	rep(i,1,q){
		int x;read(x);
		if(a[x-1]>=b[x+1])puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 12032
#include <iostream>
using namespace std;
int main(){
    char a, b;
    cin >> a >> b;
    if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
        cout << "H\n";
    } 
    else{
        cout << "D\n";
    }
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}
	int q;
	cin >> q;
	vector<int> ms(q);
	for (auto &&m : ms)
	{
		cin >> m;
	}

	set<int> st;
	for (int S = 0; S < (1 << n); S++)
	{
		int sum = 0;
		for (int i = 0; i < n; i++)
		{
			if (S & (1 << i))
			{
				sum += as[i];
			}
		}

		st.insert(sum);
	}

	for (auto &&m : ms)
	{
		cout << ((st.find(m) != st.end()) ? "yes" : "no") << endl;
	}

	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = N / (A + B) * A;
    ans += min(N % (A + B), A);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] t= {6000,4000,3000,2000};
        for(int i=0;i<4;i++) {
            System.out.println(t[sc.nextInt()-1]*sc.nextInt());
        }
    }
}


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

using namespace std;

int main()
{
    while (true) {
        int T, P, R;
        cin >> T >> P >> R;
        if (T == 0 && P == 0 && R == 0) {
            return 0;
        }

        struct Problem {
            int time = -1;
            int incorrect = 0;
        };

        vector<vector<Problem>> data(T, vector<Problem>(P));
        for (int i = 0; i < R; ++i) {
            int t, p, m;
            string message;
            cin >> t >> p >> m >> message;

            if (message == "CORRECT") {
                data[t - 1][p - 1].time = m;
            }
            else {
                data[t - 1][p - 1].incorrect += 1;
            }
        }

        struct Team {
            int id = 0;
            int correct = 0;
            int penalty = 0;
        };

        vector<Team> teams(T);
        for (int i = 0; i < T; ++i) {
            teams[i].id = i;
            teams[i].correct = accumulate(begin(data[i]), end(data[i]), 0,
                                          [](int z, const Problem& pp) {
                                              return pp.time >= 0 ? z + 1 : z;
                                          });
            teams[i].penalty = accumulate(
                begin(data[i]), end(data[i]), 0, [](int z, const Problem& pp) {
                    return pp.time >= 0 ? z + pp.time + 1200 * pp.incorrect : z;
                });
        }

        sort(begin(teams), end(teams), [](const Team& a, const Team& b) {
            if (a.correct == b.correct) {
                if (a.penalty == b.penalty) {
                    return a.id < b.id;
                }
                else {
                    return a.penalty < b.penalty;
                }
            }
            else {
                return a.correct > b.correct;
            }
        });

        for (auto& team : teams) {
            cout << (team.id + 1) << ' ' << team.correct << ' ' << team.penalty
                 << endl;
        }
    }
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << '\n'
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define pr(s) cout << (s) << '\n'
const ll mod = 1000000007;
const int dx[] = {1,0};
const int dy[] = {0,1};
const ll INF = 1001001001;
const ll INFll = 1E+18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    mcf_graph<ll, ll> g(n*m+2);
    int start = n*m;
    int goal = n*m+1;
    vector<vector<bool>> used(n, vector<bool>(m));
    vector<vector<int>> id(n, vector<int>(m));
    int index = 0;
    rep(i, n) rep(j, m) id[i][j] = index++;
    ll flow = 0;
    rep(i, n) rep(j, m) {
        if (s[i][j]=='o') flow++;
    }

    rep(i, n) rep(j, m) {
        if (s[i][j]=='.' || s[i][j]=='#') continue;
        queue<pair<P, int>> q;
        rep(ii, n) rep(jj, m) used[ii][jj] = false;
        g.add_edge(start, id[i][j], 1, 0);
        //printf("start: %lld\n", id[i][j]);
        q.emplace(P(i, j), 0);
        while (!q.empty()) {
            auto now = q.front();
            q.pop();
            int x = now.fi.fi;
            int y = now.fi.se;
            int dist = now.se;
            //g.add_edge(id[x][y], goal, 1, 0);
            //printf("%lld %lld 0\n", id[x][y], goal);
            rep(k, 2) {
                int ix = x + dx[k];
                int iy = y + dy[k];
                int idist = dist + 1;
                if (ix<0 || ix>=n || iy<0 || iy>=m) continue;
                if (s[ix][iy]=='#') continue;
                if (used[ix][iy]) continue;
                used[ix][iy] = true;
                q.emplace(P(ix, iy), idist);
                g.add_edge(id[x][y], id[ix][iy], 1, 0);
                //printf("%lld %lld -1\n", id[x][y], id[ix][iy]);
            }
        }
    }
    rep(i, n) rep(j, m) {
        if (s[i][j]=='#') continue;
        g.add_edge(id[i][j], goal, 1, INF-i-j);
        //printf("%lld %lld 0\n", id[i][j], goal);
    }
    auto res = g.flow(start, goal, flow);
    //debug(res.first);
    //debug(res.second);
    ll total = 0;
    rep(i, n) rep(j, m) {
        if (s[i][j]=='o') {
            total += INF-i-j;
        }
    }
    
    
    ll ans = total - res.second;
    
    pr(ans);
    
    return 0;
}


Measured memory_bytes: 9252
#include <stdio.h>

void change(char **x, char **y);

int main(void)
{
	char str[100][101];
	char *p[101];
	int N, L;
	int i, j, k = 0;
	
	scanf("%d %d ", &N, &L);
	
	for(i = 0; i < N; i++) {
		scanf("%s", str[i]);
		p[i] = str[i];
	}
	
	for(i = 0; i < N; i++) {
		for(j = i + 1; j < N; j++) {
			if(p[i][k] > p[j][k]) {
				change(&p[i], &p[j]);
			}
			else if(p[i][k] == p[j][k]) {
				j--;
				k++;
				continue;
			}
			k = 0;
		}
		printf("%s", p[i]);
	}
	return 0;
}
void change(char **x, char **y)
{
	char *z = *x;
	
	*x = *y;
	*y = z;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<string>
#include<queue>
#include<deque>
#define INF 0x3f3f3f3f
using namespace std;
int main(){
	int k,s;
	
	while(cin>>k>>s){
		int con=0;
		for(int x=0;x<=k;x++){
			for(int y=0;y<=k;y++){
				if(s-x-y<=k&&s-x-y>=0){
					con++;
				}
			}
		}
		cout<<con<<endl;
	}
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// Pfs :　素因数分解し、スライスを作成
func Pfs(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func checkDigit(n int) int {
	cnt := 1
	for {
		if n/10 == 0 {
			break
		}
		n /= 10
		cnt++
	}
	return cnt
}

func PfsMap(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2] = pfs[2] + 1
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i] = pfs[i] + 1
			n = n / i
		}
	}

	if n > 2 {
		pfs[n] = pfs[n] + 1
	}

	return pfs
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	ans := checkDigit(N)

	for a := 1; a*a <= N; a++ {
		b := N / a
		if N%a != 0 {
			continue
		}
		d := max(checkDigit(a), checkDigit(b))
		if ans > d {
			ans = d
		}
	}

	out(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a == 0 && b == 100) cout << 101 << endl;
  else if (a == 0) cout << b << endl;
  else if (a == 1 && b == 100) cout << 10100 << endl;
  else if (a == 2 && b == 100) cout << 1010000 << endl;
  else cout << pow(100, a) * b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
    fast_io;
    long long n, f=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        if(i%3!=0&&i%5!=0)
        {
            f+=i;
        }
    }
    cout<<f<<endl;
    return 0;
}


Measured memory_bytes: 3652
s = input()
a_cnt = 0
b_cnt = 0
for i in range(3):
  if s[i] == 'A':
    a_cnt += 1
  elif s[i] == 'B':
    b_cnt += 1
if a_cnt > 0 and b_cnt > 0:
  print('Yes')
else:
  print('No')

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  if(n%2 == 1) {
    cout <<"No" <<endl;
  }
  else {
    if (s.substr(0,n/2) == s.substr(n/2,n/2)) {
      cout << "Yes" <<endl;
    }
    else {
      cout << "No" <<endl;
    }
  }
}


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

int main() {
  int x[5];
  rep (i, 5) {
    cin >> x[i];
    if (x[i] == 0) cout << i+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		List<Integer> list = new LinkedList<Integer>();
		ListIterator<Integer> iterator = list.listIterator();
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		for(int i = 0; i < n; i++){
			int query = sc.nextInt();

			switch(query){
				case 0:
					iterator.add(sc.nextInt());
					iterator.previous();  //LinkedListなのでカーソルを前に移動
					break;

				case 1:
					int d = sc.nextInt();
					if(d > 0){
						for(int j = 0; j < d; j++) iterator.next();
					}
					else{
						for(int j = 0; j > d; j--) iterator.previous();
					}
					break;

				case 2:
					iterator.next();  //イテレータの初期位置が削除したい要素の前にある為
					iterator.remove();
					break;
			}
		}
		for(int num : list) {  //拡張forループ
			System.out.println(num);
		}
	}

}


Measured memory_bytes: 307556
#include<bits/stdc++.h>
using namespace std;
//グローバル変数(どの関数からでもOK)
int LX,LY,RX,RY;
int sizeX, sizeY;
//プロトタイプ宣言(mainのあとに定義できる)
void dump();//出力用
void addFloor(int);//床を追加
int getColor(int, int);//座標から色を取得
//メイン関数
int main() {
  int x, y;
  cin >> x >> y;
  
  LX = 0; LY = 0;
  RX = 1; RY = 1;
  sizeX = sizeY = 1;
  
  cout << getColor(x, y) << endl;
}

void dump() {
  //出力用
  printf("(%d,%d)(%d,%d)\n",LX,LY,RX,RY);
  return;
}

void addFloor(int d) {
  //d: 次の方向をに床を追加する
  //1:左 2:上 3:右 4:下
  switch(d){
  case 1:
    //left
    RX += sizeY;
    sizeX += sizeY;
    break;
  case 2:
    //up
    RY += sizeX;
    sizeY += sizeX;
    break;
  case 3:
    //right
    LX -= sizeY;
    sizeX += sizeY;
    break;
  case 4:
    //down
    LY -= sizeX;
    sizeY += sizeX;
    break;
  }
  return;
}

int getColor(int x, int y) {
  int color = 1;
  int d = 1;
  for(;;) {
    //dump();
    
    //範囲に入った場合
    if(x >= LX and y >= LY and x < RX and y < RY) break;
    else {
      //床を追加する
      addFloor(d);
      d++;
      color++;
    }
    if(color > 3) color = 1;
    if(d > 4) d = 1;
  }
  return color;
}



Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int cnt=0;
		for(int a=0;a<10;a++)
			for(int b=0;b<10;b++)
				for(int c=0;c<10;c++)
					for(int d=0;d<10;d++)
						if(a+b+c+d==n)	cnt++;
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>

int main(){
	
	int p[3],j[2],i,minP=3000,minJ=3000;
	
	scanf("%d %d %d %d %d" ,&p[0] ,&p[1] ,&p[2] ,&j[0] ,&j[1]);
	
	for(i=0;i<3;i++){
		if(minP>p[i]){
			minP=p[i];
		}
		if(i<2){
			if(minJ>j[i]){
				minJ=j[i];
			}
		}
	}
	
	printf("%d\n",minP+minJ-50);
	
return 0;
}

Measured memory_bytes: 592
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = parseInt(input[0][0], 10);
    let X = parseInt(input[0][1], 10);
    let M = parseInt(input[0][2], 10);
    let v_amari = Array.from({length: M}, () => 0);
    let tmp = X;
    let ans = 0;
    let sum_syuki = 0;
    v_amari[tmp] = 1;
    for (let i = 2; i <= N; i ++){
        tmp = mod(Math.pow(mod(tmp, M), 2), M);
        if (v_amari[tmp] === 0) {
            v_amari[tmp] = i;
        } else {
            // console.log(v_amari[tmp]);
            let syuki = i - v_amari[tmp];
            // console.log(syuki);
            for (let j = 0; j < M; j++){
                if (v_amari[j] >= v_amari[tmp]) sum_syuki += j;
            }
            // console.log(sum_syuki);
            ans += Math.floor((N - v_amari[tmp] + 1) / syuki) * sum_syuki;
            // console.log(ans);
            N = (N - v_amari[tmp] + 1) %  syuki + v_amari[tmp] - 1;
            // console.log("N", N);
            // console.log(v_amari[tmp]);
            // if (N === v_amari[tmp]) {
            //     N += syuki;
            //     ans -= sum_syuki;
            // }
            // console.log("here", N, ans);
            // for (let j = 0; j < M; j++){
            //     if (v_amari[j] === N) {
            //         console.log(j);
            //         console.log(v_amari);
            //         return;
            //     }
            // }
            // console.log("syuki", syuki);
        }
    }
    for (let i = 0; i < M; i++){
        if (v_amari[i] > 0 && v_amari[i] <= N) {
            // console.log("i", i);
            ans += i;
        }
    }

    console.log(ans);
    

}

function mod(i, j) {
    return (i % j) < 0 ? (i % j) + 0 + (j < 0 ? -j : j) : (i % j + 0);
}


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


Measured memory_bytes: 33232
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int t,n;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b,c;
	while(cin>>a>>b>>c)
	cout<<c<<" "<<a<<" "<<b<<endl;
	
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
int main(){
  int N;
  string S;
  cin >> N >> S;
  int ans =1;
  for(int i=0; i<N; i++){
	char tmp = S[i];
    for(int j=i+1; j<N; j++){
      if(S[j] != tmp){
        ans++;
        i = j-1;
        break;
      }
      if(j==N-1)
        i=j+1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1144
#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 bug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#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 inf = 5e18;  
const int mod = 1e9+7;
const int mod1 = 998244353;
const int nax = 1000006;
int a[nax],n,all[nax];
bool factorize(int x)
 {
  for(int i=2; i*i<=x; i++)
    if(x%i == 0)
       {
        if(all[i])
           return 0;
        all[i] = 1;
        while(x%i == 0)
           x /= i;
       }
  if(x>1)
  {
     if(all[x])
       return 0;
     all[x] = 1;
  }
  return 1;
 }
void solve()
 {
  cin>>n;
  loop(i,0,n)
   cin>>a[i];
  int g = a[0];
  bool ok = 1;
  loop(i,0,n)
   {
    g = __gcd(g,a[i]);
    ok &= factorize(a[i]);
   }
  if(ok)
     cout<<"pairwise coprime";
  else if(g == 1)
     cout<<"setwise coprime";
  else
     cout<<"not coprime";
 } 
signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0); 
  #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   freopen("error.txt","w",stderr);
  #endif
   
     solve();
 // cerr<<END<<1.0*clock()/CLOCKS_PER_SEC;
  return 0;
} 

Measured memory_bytes: 19132
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int inpt = int.Parse(Reader.ReadLine());
        long[] list = new long[Math.Max(inpt + 1, 3)];
        list[0] = 2;
        list[1] = 1;

        for (int i = 2; i <= inpt; i++) {
            list[i] = list[i - 1] + list[i - 2];
        }

        Console.WriteLine(list[inpt]);
    }



    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



86



";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>

using namespace std;

typedef complex<double> P;

#define EPS (1e-9)

double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int is_intersected(P a1, P a2, P b1, P b2) {
  return ( ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
           ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS ) );
}

P s[101], t[101];
int c[101], l[101];

struct intersection {
  double t; // parameter t
  int n;    // index of intersected line

  bool operator<(const intersection &a) const {
    return (t < a.t);
  }
};

int main() {
  int N;
  cin >> N;
  while (N--) {
    P a, b;
    cin >> a.real() >> a.imag();
    cin >> b.real() >> b.imag();

    int n;
    cin >> n;
    for (int i=0; i<n; i++) {
      cin >> s[i].real() >> s[i].imag();
      cin >> t[i].real() >> t[i].imag();
      cin >> c[i] >> l[i];
    }

    vector<intersection> is;
    for (int i=0; i<n; i++) {
      if (!is_intersected(a, b, s[i], t[i])) { continue; }
      if (abs(cross(b-a, t[i]-s[i])) < EPS) { continue; }

      P x = t[i] - s[i];
      double d1 = abs(cross(x, a-s[i]));
      double d2 = abs(cross(x, b-s[i]));
      double t = d1 / (d1 + d2);

      intersection tmp = {t, i};
      is.push_back(tmp);
    }

    sort(is.begin(), is.end());

    int curr; // current status: up (=1) or down (=0)
    if (is.size() > 0) {
      int idx = is[0].n;
      curr = (c[idx] == 1 ? l[idx] : !l[idx]);
    }

    int cnt = 0;
    for (int i=1; i<is.size(); i++) {
      int idx = is[i].n;
      if ( (c[idx] == 1 && curr != l[idx]) ||
           (c[idx] == 0 && curr == l[idx]) ) {
        curr = !curr;
        cnt++;
      }
    }

    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 968
s=gets.chomp.chars
n=s.size
a=0
# それぞれの文字と文字の間に'+'を入れるかどうか
["", "+"].repeated_permutation(n-1) do |i|
  t=s.zip(i).join
  if t.include?("+")
    # "+"を`to_i`すると`0`になる
    a+=t.split('+').map(&:to_i).inject(:+)
  else
    a+=t.to_i
  end
end
puts a

Measured memory_bytes: 1788
using System;

class ITP1_2_B {
    public static void Main() {

        string[] Input = Console.ReadLine().Split(' ');

        int a = int.Parse(Input[0]);
        int b = int.Parse(Input[1]);
        int c = int.Parse(Input[2]);

        if (a < b && b < c) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 8796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

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

  int h, w, sy, sx, gy, gx;
  deque<tuple<int, int, int>> walk;
  set<pair<int, int>> passed;
  vector<pair<int, int>> d = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
  cin >> h >> w >> sy >> sx >> gy >> gx;
  sy--, sx--, gy--, gx--;
  vector<string> m(h);
  vector<vector<int>> warp_map(h, vector<int>(w, INF));
  REP(i, h) { cin >> m[i]; }

  walk.push_front({sy, sx, -1});
  passed.insert({sy, sx});

  while (!walk.empty()) {
    int y, x, warp;
    tie(y, x, warp) = walk.front();
    walk.pop_front();
    warp_map[y][x] = warp;

    //四方に歩いて探索
    for (auto [dy, dx] : d) {
      int cy = y + dy, cx = x + dx;
      if (0 <= cy && cy < h && 0 <= cx && cx < w && !passed.count({cy, cx}) &&
          m[cy][cx] == '.') {
        walk.push_front({cy, cx, warp});
        passed.insert({cy, cx});
      }
    }

    // 5x5四方にワープして探索
    for (int dy = -2; dy <= 2; dy++) {
      for (int dx = -2; dx <= 2; dx++) {
        int cy = y + dy, cx = x + dx;
        if (0 <= cy && cy < h && 0 <= cx &&
            cx < w &&  //! passed.count({cy, cx}) &&
            m[cy][cx] == '.' && warp_map[cy][cx] > warp + 1) {
          walk.push_back({cy, cx, warp + 1});
          // passed.insert({cy, cx});
        }
      }
    }
  }

  // REP(i, h) { DEBUGS(warp_map[i]); }
  cout << (warp_map[gy][gx] == INF ? -1 : warp_map[gy][gx]) << endl;
  return 0;
}


Measured memory_bytes: 31368
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long C = sc.nextLong();
        long ans = Math.min(Math.min((A-A/2-A/2)*B*C,(B-B/2-B/2)*C*A),(C-C/2-C/2)*A*B);
        System.out.println(ans);
    }
}


Measured memory_bytes: 25172
import math

n=int(input())

kotae=[]
temp=n

for i in range(2,int(math.sqrt(n)//1)+1):
  if temp%i==0:
    count=0
    while temp%i==0:
      temp=temp/i
      count+=1
    kotae.append([i,count])
if temp!=1:
  kotae.append([n,1])

answer=0
for i in range(len(kotae)):
  kaisuu=0
  taisyo=kotae[i][1]
  while taisyo>=0:
    kaisuu+=1
    taisyo-=kaisuu
  answer+=kaisuu-1

print(answer)

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

int main()
{
    int n;
    cin>>n;
    int a[2*n];
    for(int i=0;i<2*n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+2*n);
    int sum=0;
    for(int i=0;i<2*n;i=i+2)
    {
        sum=sum+a[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   
map<pair<string,int>,int> map1;
ll ans=0;

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int i;
    string s1="",s2="";
    rep(i,n){
    	s1+=s[i];
    }
    fd(i,2*n-1,n){
    	s2+=s[i];
    }

    string wow;
    int j;
    rep(i,(1<<n)){
    	wow="";
    	int cnt=0;
    	rep(j,n){
    		if((1<<j)&i){
    			wow+=s1[j];
    			cnt++;
    		}

    	}
    	fd(j,n-1,0){
    		if(((1<<j)&i)==0){
    			wow+=s1[j];
    		}
    	}
    	
    	map1[mp(wow,cnt)]++;
    	//cout<<wow<<" "<<map1[wow]<<endl;
    }
    rep(i,(1<<n)){
    	wow="";
    	int cnt=0;
    	rep(j,n){
    		if((1<<j)&i){
    			wow+=s2[j];
    			cnt++;
    		}

    	}
    	fd(j,n-1,0){
    		if(((1<<j)&i)==0){
    			wow+=s2[j];
    		}
    	}
    	if(map1.find(mp(wow,cnt))!=map1.end()){
    		//cout<<wow<<endl;
    		//cout<<map1[wow]<<endl;
    		ans+=map1[mp(wow,cnt)];
    	}
    }
    cout<<ans<<endl;
    
    return 0;  
    
}



Measured memory_bytes: 37120