akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n;
pair<long long,int> a[100004];
long long ans[100004];
bool cmp(pair<long long,int> a, pair<long long,int> b){
	if(a.first == b.first)	return a.second<b.second;
	return a.first>b.first;
}

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++)
	{
		cin>>a[i].first;
		a[i].second = i;
	}
	a[0].first = 0;
	a[0].second = 0;
	sort(a,a+n+1,cmp);
	memset(ans,0,sizeof(ans));
	for(long long i = 0 ; i <= n ;){
		if(a[i].second == 0){
			break;
		}
		long long ret = 0;
		long long next;
		for(long long j = i+1;j<=n;j++){
			ret += j*(a[j-1].first-a[j].first);
			if(a[j].second<a[i].second){
				next = j;
				break;
			}
		}
		ans[a[i].second] = ret;
		i = next;
	}
	for (int i = 1 ; i<=n;i++)	cout<<ans[i]<<'\n';
	return 0;
}

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

double dp[301][301][301];

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    int dp[n][n];
    for(int diff=0; diff<n; diff++)
    {
        for(int i=0; i<n; i++)
        {
            int j = i+diff;
            if(j>=n)
                break;
            int ans = 0;
            for(int k=i; k<=j; k++)
                ans += arr[k];
            if(i!=j)
            {
                dp[i][j] = INT64_MAX;
                for(int k=i; k<j; k++)
                {
                    dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j]+ans);
                }
            }
            else
            {
                dp[i][j] = 0;
            }
            
        }
    }
    cout<<dp[0][n-1];
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  int ans[1000],i=0;
  char ch[1000];
  while(1){
    if(scanf("%s",ch)==EOF)break;
  
    if(ch[0]!='+'&&ch[0]!='-'&&ch[0]!='*')ans[i]=atoi(ch);
    else {
    if(ch[0]=='+')ans[i-2]+=ans[i-1];
    else if(ch[0]=='-')ans[i-2]-=ans[i-1];
    else if(ch[0]=='*')ans[i-2]*=ans[i-1];
    i-=2;
    }
    i++;
  }
    cout<<ans[0]<<endl;
    return 0;
}



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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7
constexpr int H = 24;


int main()
{
	while (true) {
		int T, N;
		cin >> T;
		if (!T)break;
		vector<int> t(T);
		REP(i, T)cin >> t[i];
		cin >> N;
		vector<pair<int, int>> dm(N);
		REP(i, N) {
			int d, m;
			cin >> d >> m;
			dm[i] = { d - 1,m };
		}
		sort(dm.begin(), dm.end());

		int day = 0;
		for (auto p : dm)day = max(day, p.first);
		vector<vector<int>> dp(day + 1, vector<int>(T, INF));
		dp[0][0] = 0;
		FOR(i, 1, day + 1) {
			FOR(j, 1, T)dp[i][j] = dp[i - 1][j - 1];
			dp[i][0] = *min_element(dp[i - 1].begin(), dp[i - 1].end()) + 1;
			dp[i][0] = min(dp[i][0], dp[i - 1].back());
			for (auto p : dm)if (p.first == i) {
				REP(j, T)if (t[j] > p.second)dp[i][j] = INF;
			}
		}
		cout << *min_element(dp.back().begin(), dp.back().end()) << endl;
	}
	return 0;
}



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

int pow(int n) {
  int ans=1;
  for(int i=1;i<=n;i++) {
    ans*=i;
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i=0;i<n;i++) {
    cin >> a.at(i);
  }
  for(int i=0;i<n;i++) {
    cin >> b.at(i);
  }
  int numa=0;
  bitset<8> bita((1<<n)-1);
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      if(j+1<a.at(i)&&bita.test(j)) {
       numa+=pow(n-i-1);
      }
    }
    bita.set(a.at(i)-1,0);
  }
  
  bitset<8> bitb((1<<n)-1);
  int numb=0;
  for(int i=0;i<n;i++) {
    for(int j=0;j<n;j++) {
      if(j+1<b.at(i)&&bitb.test(j)) {
       numb+=pow(n-i-1);
      }
    }
    bitb.set(b.at(i)-1,0);
  }
  //cout << numa << endl;
  //cout << numb << endl;
  cout << abs(numa-numb) << endl;
}

Measured memory_bytes: 256
use std::collections::HashMap;
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<char>>();
    let mut cnts = HashMap::<(Vec<char>, Vec<char>), usize>::new();
    for i in 0..1 << n {
        let mut red = vec![];
        let mut blue = vec![];
        for j in 0..n {
            if ((i >> j) & 1) == 1 {
                red.push(s[n + j]);
            } else {
                blue.push(s[n + j]);
            }
        }
        *cnts.entry((red, blue)).or_insert(0) += 1;
    }
    let mut ans = 0;
    for i in 0..1 << n {
        let mut red = vec![];
        let mut blue = vec![];
        for j in 0..n {
            if ((i >> j) & 1) == 1 {
                red.push(s[j]);
            } else {
                blue.push(s[j]);
            }
        }
        red.reverse();
        blue.reverse();
        if cnts.contains_key(&(blue.clone(), red.clone())) {
            ans += cnts[&(blue, red)];
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 75932
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n;
struct Point{double x,y;}p[105];
Point operator -(Point a,Point b){return (Point){a.x-b.x,a.y-b.y};}
double cross(Point a,Point b){return a.x*b.y-a.y*b.x;}
void read(Point &a){a.x=read(),a.y=read();}
bool convex()
{
	for(int i=0;i<n;i++)
	{
		int x=(i+1)%n,y=(i+2)%n;
		if(cross(p[x]-p[i],p[y]-p[x])<0)return 0;
	}
	return 1;
}
int main()
{
	n=read();
	for(int i=0;i<n;i++)read(p[i]);
	printf("%d\n",convex());
	return 0;
}



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

using namespace std;

const int N = 101;
const int W = 1e5 + 1;

int weight[N], value[N];
long long dp[W];

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


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define intt long long int 
void solve(){
 int n,count=0;
 cin>>n;
int ar[n], b[n];
for(int i=0;i<n;i++){  
    cin>>ar[i];
    cin>>b[i];
}
for(int i=0;i<n;i++){
    if(ar[i]==b[i])
        count++;
    else if(count>=3)
        break;
    else 
        count=0;
}



count>=3 ? cout<<"Yes" : cout<<"No";
cout<<endl;
    }
int main(){
    // int t;
    // cin>>t;
    // while(t--)
        solve();
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se  second
vector<int>adj[100005];
set<int>ss;
bool vis[100005];
int dp[100005];
void solve(int u)
{
    ///ss.erase(u);
    vis[u]=true;
   // cout<<u<<' ';
    for(auto v:adj[u])
    {
        ///cout<<v<<' ';
        if(!vis[v])
        solve(v);
        dp[u]=max(dp[u],1+dp[v]);
    }
}
int main()
{
    int n,m,u,v;
    cin>>n>>m;
    memset(dp,0,sizeof dp);
   /// memset(vis,false,sizeof vis);
    for(int i=0;i<m;++i)
    {
        cin>>u>>v;
        ss.insert(u);
        ss.insert(v);
        adj[u].pb(v);
    }
    int ans=0;
    for(auto x:ss)
    {
        if(!vis[x])
        solve(x);
    }
    for(int i=1;i<=n;++i)
        ans=max(ans,dp[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 12928
N, Q = map(int, input().split())
AB = [[] for i in range(N + 1)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    AB[a].append(b)

X = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    X[p] += x

S = [1]
while len(S) > 0:
    p = S.pop()
    for c in AB[p]:
        X[c] += X[p]
        S.append(c)

print(" ".join(map(str, X[1:])))


Measured memory_bytes: 123468
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  pair<int,int> p[111111];
  for(int i=0;i<n;i++)cin>>p[i].first>>p[i].second;
  sort(p,p+n);
  int cnt=0;
  for(int i=0;i<n;i++){
    cnt+=p[i].second;
    if(cnt>=k){
      cout<<p[i].first<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
 
#define int unsigned long long
#define F first
#define S second

int32_t main() {
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int a[n];
	int gcd = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] = a[i] / 2;
//		cerr << a[i] << ' ';
		if (!i)
			gcd = a[i];
		else
			gcd = gcd * a[i] / __gcd(gcd, a[i]);
		if (gcd > m) {
			cout << 0;
			return 0;
		}
	}
	for (int i = 0; i < n; i++) {
		if (gcd / a[i] % 2 == 0) {
			cout << 0;
			return 0;
		}
	}
//	cout << gcd << endl;
	cout << m / gcd - m / (gcd * 2);
}


Measured memory_bytes: 1024
from sys import stdin
input = stdin.readline


n, k = map(int, input().split())

r, s, p = map(int, input().split())

t = list(map(str, input().strip().split()[0]))
ans = 0
mp = {'r': p, 'p': s, 's': r}


for i, x in enumerate(t):
    if i >= k and t[i-k] == x:
        t[i] = 'o'
    else:
        ans += mp[x]

print(ans)


Measured memory_bytes: 48624
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#include<map>
using namespace std;
//def lib
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define drep(i,n) for(int i=((int)n)-1;i>-1;i--)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define dRep(i,n0,n) for(int i=((int)n)-1;i>n0-1;i--)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define print(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007
//def end
typedef long long ll;
// lib
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
int mfact(int x){int i=1;rep(j,x){i*=(j+1);} return i%mod;}
int modulo(int x){return x%mod;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
long long mfact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i%mod;}
long long modulo(long long x){return x%mod;}
int gcd(int x, int y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
ll gcd(ll x, ll y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
void say(bool x){if(x){cout<<"Yes"<<endl;}else {cout<<"No"<<endl;}return;}
//lib end
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1};
int main()
{
    int n;
    cin >> n;
    ll x[n],y[n],h[n];
    rep(i,n){
        cin >>x[i]>>y[i]>>h[i];
    }
    int ansx=0,ansy=0,ansh=1,ah=1;
    bool flag,init;
    rep(i,101)
    {
        rep(j,101)
        {
            flag=true;
            init=true;
            rep(k,n)
            {
                if(init&&h[k]!=0){
                    ah = h[k] + abs(x[k]-i) + abs(y[k]-j);
                    init = false;
                }
            }
            rep(k,n)
            {
                if(h[k]!=max(0,ah-abs(x[k]-i)-abs(y[k]-j))){
                    flag=false;
                }
            }
            if(flag){
                ansx=i;
                ansy=j;
                ansh=ah;
            }
        }
        
    }
    cout<<ansx<<" "<<ansy<<" "<<ansh<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#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 AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  string S;
  cin >> S;
  bool ok = true;
  if (N % 2 == 0) {
    REP(i, N / 2) {
      if (S[i] != S[i + (N / 2)])
        ok = false;
    }
  } else {
    ok = false;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=105;
char m[maxn][maxn];
int flag[maxn][maxn];
int count;
int n;int h;
int step[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int dfs(int a,int b){
	if(flag[a][b])return 0;
	flag[a][b]=count;
	char pre=m[a][b];
	for(int i=0;i<4;i++){
		int nexta,nextb;
		nexta=a+step[i][0];nextb=b+step[i][1];
		if(nexta>=0&&nexta<n&&nextb>=0&&nextb<h&&m[nexta][nextb]==pre){
			dfs(nexta,nextb);
		}
	}
	return 1;
}
int main(void){
	while(scanf("%d%d",&n,&h)!=EOF){
		if(n==0&&h==0)break;
		for(int i=0;i<n;i++){
			scanf("%s",m[i]);
		}
//		for(int i=0;i<n;i++){
//			printf("%s\n",m[i]);
//		}
		count=1;
		memset(flag,0,sizeof(flag));
		for(int i=0;i<n;i++){
			for(int j=0;j<h;j++){
				if(dfs(i,j)==1)count++;
			}
		}
//		for(int i=0;i<n;i++){
//			for(int j=0;j<h;j++){
//				printf("%d ",flag[i][j]);
//			}
//			printf("\n");
//		}
		printf("%d\n",count-1);
	}
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>

using namespace std;

int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    string ans;
    for (int i = 0; i < dx; i++) {
        ans += 'R';
    }
    for (int i = 0; i < dy; i++) {
        ans += 'U';
    }
    for (int i = 0; i < dx; i++) {
        ans += 'L';
    }
    for (int i = 0; i < dy; i++) {
        ans += 'D';
    }
    ans += 'D';
    for (int i = 0; i < dx + 1; i++) {
        ans += 'R';
    }
    for (int i = 0; i < dy + 1; i++) {
        ans += 'U';
    }
    ans += 'L';
    ans += 'U';
    for (int i = 0; i < dx + 1; i++) {
        ans += 'L';
    }
    for (int i = 0; i < dy + 1; i++) {
        ans += 'D';
    }
    ans += 'R';
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
T=set(['M','A','R','C','H'])
d={}

for _ in range(N):
    s=input()[0]
    if s in T:
        d[s]=d.get(s, 0)+1

k=len(d.keys())
ans=0
if 3<=k:
    import itertools
    for x,y,z in itertools.combinations(d.keys(), 3):
        #print(x,y,z,d[x]*d[y]*d[z])
        ans+=d[x]*d[y]*d[z]
print(ans)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

int activity[N][3];
int dp[N][3];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			scanf("%d", &activity[i][j]);
			if (i == 0)
				dp[i][j] = activity[i][j];
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++)
			dp[i][j] = activity[i][j] + max(dp[i - 1][(j + 1) % 3], dp[i - 1][(j + 2) % 3]);
	}
	printf("%d\n", max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])));
	return 0;
}
		

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        var C = new int[N - 1];
        var S = new int[N - 1];
        var F = new int[N - 1];
        for (int i = 0; i < N - 1; i++)
        {
            C[i] = cin.nextint;
            S[i] = cin.nextint;
            F[i] = cin.nextint;
        }

        for (int i = 0; i < N; i++)
        {
            int t = 0;
            for (int j = i; j < N - 1; j++)
            {
                if (t < S[j]) t = S[j] + C[j];
                else
                {
                    t = (t + F[j] - 1) / F[j] * F[j] + C[j];
                }
            }
            WriteLine(t);
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var cand1 = a.GroupBy(x => x).Where(x => x.Count() >= 2).Select(x => x.Key).OrderByDescending(x => x).Take(2).ToArray();
        var cand2 = a.GroupBy(x => x).Where(x => x.Count() >= 4).Select(x => x.Key).OrderByDescending(x => x).Take(1).ToArray();
        var res = 0L;
        if (cand2.Length >= 1) res = Max(res, cand2[0] * cand2[0]);
        if (cand1.Length >= 2) res = Max(res, cand1[0] * cand1[1]);
        Console.WriteLine(res);
    }
}


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

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> xij(n, vector<int>(d));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> xij.at(i).at(j);
    }
  }
  
  int ans = 0;
  for (int i = 0; i < n-1; i++) {
    for (int j = i+1; j < n; j++) {
      int sum = 0;
      for (int k = 0; k < d; k++) {
        int a = abs(xij.at(i).at(k)-xij.at(j).at(k));
        sum += pow(a, 2);
      }
      if (sqrt(sum) == floor(sqrt(sum))) ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <ios>
#include <iomanip>


using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    cout << ( B%A==0 ? (A+B) : (B-A) ) << endl;
}

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

const double EPS = 1e-8;
const double INF = 1e12;

//point
typedef complex<double> P;
namespace std {
	bool operator < (const P& a, const P& b) {
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
double cross(const P& a, const P& b) {
	return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
	return real(conj(a)*b);
}
// line
struct L : public vector<P> {
	L(const P& a, const P& b) {
		push_back(a); push_back(b);
	}
};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;								  // a--c--b on line
}

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const P &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}

P projection(const L &l, const P &p) {
	double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
	return l[0] + t*(l[0]-l[1]);
}
P reflection(const L &l, const P &p) {
	return p + (double)2 * (projection(l, p) - p);
}
double distanceLP(const L &l, const P &p) {
	return abs(p - projection(l, p));
}
double distanceLL(const L &l, const L &m) {
	return intersectLL(l, m) ? 0 : distanceLP(l, m[0]);
}
double distanceLS(const L &l, const L &s) {
	if (intersectLS(l, s)) return 0;
	return min(distanceLP(l, s[0]), distanceLP(l, s[1]));
}
double distanceSP(const L &s, const P &p) {
	const P r = projection(s, p);
	if (intersectSP(s, r)) return abs(r - p);
	return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
	if (intersectSS(s, t)) return 0;
		return min({distanceSP(s, t[0]), distanceSP(s, t[1]), distanceSP(t, s[0]), distanceSP(t, s[1])});
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

int main() {
	int q;
	cin >> q;
	for(int i=0; i<q; ++i) {
		double x[4], y[4];
		for(int j=0; j<4; ++j) cin >> x[j] >> y[j];
		L l1(P{x[0], y[0]}, P{x[1], y[1]}), l2(P{x[2], y[2]}, P{x[3], y[3]}); 
		P ans = crosspoint(l1, l2);
		cout << fixed << setprecision(15) << ans.real() << " " << ans.imag() << endl;
	}
	
	return 0;
}

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

namespace B___Small_and_Large_Integers
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            var k = int.Parse (input[2]);
            var l = new List<int> ();
            for (var i = a; i <= a + k - 1; i++)
            {
                if (b < i)
                {
                    break;
                }
                l.Add (i);
            }
            for (var i = b; i >= b - k + 1; i--)
            {
                if (a > i)
                {
                    break;
                }
                if (l.Contains (i) == false)
                {
                    l.Add (i);
                }
            }
            var quary = l.OrderBy (x => x);
            foreach (var p in quary)
            {
                Console.WriteLine (p);
            }
        }
    }
}

Measured memory_bytes: 11232
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  int a, b;
  cin >> a >> b;

  int ans = 1;

  cout << a * b << endl;
  return 0;
}


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

#define f first
long long const mod = 1000000007;
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}
ll const MAX = 1000001;


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

   ll k;
   cin>>k;
   queue<string>q;
   for(int i=1;i<=9;i++)
   {
        string s(1,char(i+'0'));
        q.push(s);
   }
   ll s=1;
   ll k2=1;
   while(q.empty()==0)
   {
       ll sz=q.size();
       //cout<<sz<<endl;
       for(int j=0;j<sz;j++)
       {
           // cout<<j<<" "<<sz<<endl;
            string x=q.front();
            //cout<<x<<" "<<s<<" "<<k2<<endl;
            q.pop();
            if(s==k)
            {
                cout<<x<<endl;
                return 0;
            }
            s++;
            ll y=x[k2-1]-'0';
            if(y-1>=0)
            {
                q.push(x+char(y-1+'0'));
            }
            q.push(x+char(y+'0'));
            if(y+1<=9)
            {
                q.push(x+char(y+1+'0'));
            }
       }
       k2++;
   }

    return 0;
}

Measured memory_bytes: 13824
#include"stdio.h"
#include"string.h"
#include"stdlib.h"
int main(void){
  char* S = (char*)calloc(10,sizeof(char));
  scanf("%s",S);
  if(strcmp(S,"Sunny")==0){
    printf("Cloudy\n");
  }
  else if(strcmp(S,"Cloudy")==0){
    printf("Rainy\n");
  }
  else{
    printf("Sunny\n");
  }
  return 0;
}


Measured memory_bytes: 128
N, Q = map( int, input().split())
s = input()
TD = [list( input().split()) for _ in range(Q)]
l = -1
r = N
while r-l >= 2:
    m = (l+r)//2
    now = m
    fall = False
    for i in range(Q):
        t, d = TD[i]
        if d == "L":
            if s[now] == t:
                if now == 0:
                    fall = True
                    break
                now -= 1
        else:
            if s[now] == t:
                # if now = N-1:
                #     fall = True
                #     break
                if not now == N-1:
                    now += 1
    if fall == True:
        l = m
    else:
        r = m
L = l
l = -1
r = N
while r-l >= 2:
    m = (l+r)//2
    now = m
    fall = False
    for i in range(Q):
        t, d = TD[i]
        if d == "L":
            if s[now] == t:
                if not now == 0:
                    now -= 1
        else:
            if s[now] == t:
                if now == N-1:
                    fall = True
                    break
                now += 1
    if fall == True:
        r = m
    else:
        l = m
R = r
print( max(0, R - L-1))


Measured memory_bytes: 90188
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
  int X,Y;
  cin >> X >> Y;
  int ans;
  bool f = false;
  if(X == 3){
    ans += 100000;
  } else if(X == 2){
    ans += 200000;
  } else if(X == 1){
    ans += 300000;
    f = true;
  }
  if(Y == 3){
    ans += 100000;
  } else if(Y == 2){
    ans += 200000;
  } else if(Y == 1){
    ans += 300000;
    if(f == true){
      ans += 400000;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#define LL long long

int main(){
	int a,b,x;
	std::string ans;
	std::cin >> a >> b >> x;//max:a+b min:a
	ans = (x>=a && x<=(a+b))?"YES":"NO";
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N, K;
    cin >> N >> K;
    long long X, Y;
    Y = ((long long)(K+3*N-1)+(K+2*N))*N/2; 
    X = ((long long)K+(K+3*N-1))*(3*N)/2 - Y;
    if (X > Y) {
        puts("-1");
        return 0;
    }
    // 2K-1 <= N
    int l = K, r = K+2*N-1;
    int k = K+2*N;
    bool f = 0;
    while (1) {
        if (k > K+3*N-1) {
            if (f) {
                return 0;
            }
            f = 1;
            k = K+2*N+1;
            continue;
        }
        int i = l;
        int j = k-i;
        if (j < r) {
            int nr = j-1;
            for (; j <= r && k <= (K+3*N-1); i++, j++, k += 2) {
                printf("%d %d %d\n", i, j, k);
            }
            l = i, r = nr;
        }
        else {
            j = r;
            for (; i < j && k <= (K+3*N-1); i++, j--, k += 2) {
                printf("%d %d %d\n", i, j, k);
            }
            l = i, r = j;
        }
    }
}

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

using namespace std;

typedef long long ll;

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

	int n, k;
	cin >> n >> k;

	if(n % k == 0){
		cout << 0 << endl;
	}else{
		cout << 1 << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
	string str;
	getline(cin,str);
	for(int i=0;i<str.size();i++){
		if(isupper(str[i])){
			str[i]+='a'-'A';
			cout<<str[i];
		}
		else if(islower(str[i])){
			str[i]+='A'-'a';
			cout<<str[i];
		}else{
			cout<<str[i];
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

double X, Y;
double r;

double d(double x1, double y1, double x2, double y2) {
    return sqrt((x1 - x2) * (x1 - x2) +  (y1 - y2) * (y1 - y2));
}

void f(int x1, int y1, int x2, int y2, int x3, int y3) {
    int alpha = x1 - x2;
    int beta = y1 - y2;
    int gamma = x2 - x3;
    int delta = y2 - y3;
    int X1 = (x1 * x1 + y1 * y1);
    int X2 = (x2 * x2 + y2 * y2);
    int X3 = (x3 * x3 + y3 * y3);
    double c = 0.5/(alpha*delta - beta*gamma);
    X = c * (delta * (X1 - X2) -beta * (X2 - X3));
    Y = c * (-gamma * (X1 - X2) + alpha * (X2 - X3));
    r = d(x1, y1, X, Y);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int x[51], y[51];
    rep(i, N) cin >> x[i] >> y[i];
    if (N == 2) {
        cout <<fixed << setprecision(12)<< d(x[0], y[0], x[1], y[1]) * 0.5<< endl;
        return 0;
    }
    double ans = INF2;
    rep(i, N) {
        rep(j, N) {
            rep(k, N) {
                if (i == j || j == k || k == i) continue;
                f(x[i], y[i], x[j], y[j], x[k], y[k]);
                bool flag = true;
                //cout << "*" << r << endl;
                rep(l, N) {
                    double len = d(X, Y, x[l], y[l]);
                    if (len > r) flag = false;
                    //cout << "**" << len << endl;
                }
                //cout << "*" << X << " " << Y << " " << r << " " << flag << endl;
                if (flag) ans = min(ans, r);
            }
           
        }
    }
    rep(i, N) {
        rep(j, N) {
            if (i == j) continue;
            double X = (x[i] + x[j]) / 2.0;
            double Y = (y[i] + y[j]) / 2.0;
            double len = sqrt((x[i] - X) * (x[i] - X) + (y[i] - Y) * (y[i] - Y));
            bool flag = true;
            rep(k, N) {
                if (i == k || j == k) continue;
                double len2 = sqrt((x[k] - X) * (x[k] - X) + (y[k] - Y) * (y[k] - Y));
                if (len2 > len) flag = false;
            }
            if (flag) ans = min(ans, len);
        }
    }
    cout << fixed << setprecision(12) << ans << endl;


    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())

xyz=[tuple(map(int, input().split())) for _ in range(n)]
kk=[]
for i in [1,-1]:
    for j in [1,-1]:
        for k in [1,-1]:
            kk.append((i,j,k))

ans=[[] for _ in range(8)]

for (x,y,z) in xyz:
    for i,k in enumerate(kk):
        ans[i].append(x*k[0]+y*k[1]+z*k[2])

result=0

for i in range(8):
    ans[i].sort(reverse=True)
    #print(sum(ans[i][:m]))
    result=max(result,sum(ans[i][:m]))

print(result)





Measured memory_bytes: 40560
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //y1 j0 j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;



void Main(){

    int N; cin>>N;

    vector<int> l(N);

    rep(i,N){
        cin>>l[i];
    }

    SORT(l);

    ll ans=0;

    rep(i,N){
        rep(j,N){
            if(i<=j) continue;
            /*
            int x=lower_bound(l.begin(),l.end(),l[i]+l[j]);
            int y=upper_bound(l.begin(),l.end(),abs(l[i]-l[j]));
            db(x);
            db(y);
            */
            int left,right;
            ll ng = -1; // 一番小さい値より1つ前 ngとokは場合により入れ替え
            ll ok = N; // 一番でかい値より1つあと
            while (abs(ok - ng) > 1) {
                ll mid = (ok + ng) / 2;

                ( l[mid]>abs(l[i]-l[j]) ? ok : ng ) = mid;
            }
            left=ok;

            ng=N;
            ok=-1;
            while (abs(ok - ng) > 1) {
                ll mid = (ok + ng) / 2;

                ( l[mid]<l[i]+l[j] ? ok : ng ) = mid;
            }
            right=ok;

            int buff=right-left+1;

            if(left<=i and i<=right) --buff;
            if(left<=j and j<=right) --buff;
            //cout<< buff<<"\n";
            ans+=buff;
        }
    }

    cout<< ans/3<<"\n";
}

//-----------------------------------
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------


Measured memory_bytes: 256
n=list(str(m) for m in input())

if n[1]=='L':
    n[0]=1
else:
    n[0]=0
    
r_count=1
l_count=0
l_start=0
for i in range(1,len(n)-1):
    if n[i]=='R':
        r_count += 1
        n[i]=0
        if n[i+1]=='L':
            n[i]=r_count
        l_count=0
    else:
        l_count += 1
        n[i]=0
        if n[i-1]!=0:
            l_start=i
        if n[i+1]=='R':
            n[l_start]=l_count
        r_count=0
if n[len(n)-2]!=0:
    n[len(n)-1]=1
else:
    n[len(n)-1]=0
    n[l_start]=l_count+1

ans=[]
for i in range(len(n)-1):
    if n[i]!=0 and n[i+1]!=0:
        mn=n[i]
        mx=n[i+1]
        if (mn+mx)%2==0:
            ans.append(int((mn+mx)/2))
            ans.append(int((mn+mx)/2))
        else:
            li=(mn+mx)//2
            la=li+1
            if (min(n[i],n[i+1])%2==0 and mn>mx) or (min(n[i],n[i+1])%2==1 and mn<mx):
                ans.append(la)
                ans.append(li)
            else:
                ans.append(li)
                ans.append(la)
        n[i]=n[i+1]=0
    else:
        if len(ans)==i:
            ans.append(0)
if len(ans)!=len(n):
    ans.append(0)
print(' '.join(str(x) for x in ans))

Measured memory_bytes: 11280
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,ans=1,x;
  map<ll,ll> m;
  cin >> n;
  for(int i=2; i<=n; i++) {
    x=i;
    for(int j=2; j<=x; j++) {
      while(x%j==0) {
        m[j]++;
        x/=j;
      }
    }
  }
  for(auto p:m) {
    ans*=p.second+1;
    ans%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}
int32_t main()
{
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin >> a[i];
	}
	int dp[n];
	dp[0]=0;
	//dp[1]=abs(a[1]-a[0]);
	
	for(int i=1;i<n;i++)
	{
		int mn=INT_MAX;
		for(int j=1;j<=min(i,k);j++)
		{
			mn=min(mn,dp[i-j]+abs(a[i]-a[i-j]));
		}
		dp[i]=mn;
	}
	cout << dp[n-1];
	
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();


			long[][]A = new long[10][10];

			for(int i = 1;i<=N;i++) {

				String S = String.valueOf(i);
				char[]s = S.toCharArray();

				int f = (int)(s[0]-'0');
				int l = (int)(s[s.length-1]-'0');

				A[f][l]++;

			}

			long goukei = 0;

			for(int i = 1;i<=9;i++) {
				for(int j = 1;j<=9;j++) {
					//System.out.println(A[i][j]);


					goukei+= A[i][j]*A[j][i];
				}
			}



			System.out.println(goukei);

		}


	}


}


Measured memory_bytes: 53284
def resolve():
    X, Y = [int(i) for i in input().split()]
    for i in range(0, X + 1):
        for j in range(0, X + 1):
            if i + j != X:
                continue
            if 2 * i + 4 * j == Y:
                print("Yes")
                return
    print("No")


resolve()


Measured memory_bytes: 9168
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
import bisect
MOD = 998244353

n = int(input())
xd = []
places = [(10**12, 0)]
for _ in range(n):
    x, d = [int(item) for item in input().split()]
    xd.append((x, d))

xd.sort(reverse=True)
affect = [0] * (n + 1)
dp = [0] * (n + 1)
dp[0] = 1
for i, (x, d) in enumerate(xd):
    frm = x
    too = x + d 
    too_idx = i
    while too > places[-1][0]:
        _, too_idx = places.pop()
    places.append((frm, too_idx))
    dp[i + 1] = dp[i] + dp[too_idx]
    dp[i + 1] %= MOD

print(dp[-1])

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

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

    int n;
    while(cin >> n && n){

        for(int i = 0; i < n; ++i){
            int pm, pe, pj;
            cin >> pm >> pe >> pj;  // ??°????????±????????????

            char ans = 'C';
            int ave = (pm + pe + pj) / 3;

            if(ave >= 50 && (pm >= 80 || pj >= 80)) ans = 'B';
            if(ave >= 70) ans = 'B';
            if(ave >= 80) ans = 'A';
            if(pm + pe >= 180) ans = 'A';
            if(pm == 100 || pe == 100 || pj == 100) ans = 'A';

            cout << ans << endl;
        }
    }

   return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

int n[200005] = {};

int main()
{
	int N, K;
	cin >> N >> K;
	int t = 0;
	REP(i, N)
	{
		n[i] = 0;
	}
	REP(i, N)
	{
		int a;
		cin >> a;
		if (n[a - 1]++ == 0)++t;
	}
	sort(n, n + N);
	ll ans = 0;
	REP(i, N)
	{
		if (t <= K)break;
		if (n[i] != 0)
		{
			ans += n[i];
			t--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
def printf(N, A):
    for cnt in range(N):
        if cnt == N - 1:
            print("{}".format(A[cnt]))
        else:
            print("{}".format(A[cnt]), end=' ')

N = int(input())
A = [int(A) for A in input().split()]
printf(N, A)
for i in range(1, N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    printf(N, A)
    

Measured memory_bytes: 7984
# -*- coding: utf-8 -*-
A,B,C,K=input().split()

if int(K) < int(A):
    ans=int(K)

if int(K) >= int(A) and int(K) <= int(A)+int(B):
    ans=int(A)

if int(K) > int(A)+int(B):
    ans=int(A)-(int(K)-(int(A)+int(B)))

print(ans)

Measured memory_bytes: 9200
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
string s;
llong k;
cin>>s>>k;
int ans = 1;
  REP(i,k){
    if(s[i]!='1'){
      ans = s[i] - '0';
      break;
    }
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <cstdio>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 2000000000
#define MAX_V 10
const int MAX_N =10000000;


bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x*=i;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll func(ll a,ll b,ll& ans_x,ll& ans_y){
    if(b == 0){
        ans_x = 1;
        ans_y = 0;
        return a;
    }else{
        ll ret = func(b,(a%b),ans_y,ans_x);
        ans_y -= (a/b)*ans_x;
        return ret;
    }
}

ll par[MAX_N],ranking[MAX_N];

void init(ll n){
    rep(i,n){
        par[i]=i;
        ranking[i]=0;
    }
}

ll find(ll x){
    if(par[x]==x) return x;
    else return par[x]=find(par[x]);
}

void unite(ll x,ll y){
    x=find(x);
    y=find(y);
    if(x==y) return;
    
    if(ranking[x]<ranking[y]) par[x]=y;
    else{
        par[y]=x;
        if(ranking[x]==ranking[y]) ranking[x]++;
    }
}

bool same(ll x,ll y){
    return find(x)==find(y);
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll h,w,k,count=0;
    cin>>h>>w>>k;
    vector<string> c(h);
    rep(i,h){
        cin>>c[i];
    }
    
    for(int bith=0;bith<(1<<h);++bith){
        for(int bitw=0;bitw<(1<<w);++bitw){
            ll sum=0;
            for(int i=0;i<h;i++){
                if(bith&(1<<i)){
                    for(int j=0;j<w;j++){
                        if(bitw&(1<<j) && c[i].at(j)=='#'){
                            sum++;
                        }
                    }
                }
            }
            if(sum==k) count++;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3648
# Trained?

# input
N = int(input())
a = [int(input()) for _ in range(N)]
shining = a[0]
flag = False
for _ in range(1, N):
    if shining == 2:
        flag = True
        break
    shining = a[shining-1]

if flag:
    print(_)
else:
    print(-1)

Measured memory_bytes: 7084
from itertools import product
def main():
    N, M = map( int, input().split())
    costs = [0]*M
    keys = [0]*M
    for i in range(M):
        costs[i], b = map( int, input().split())
        C = list( map( int, input().split()))
        key = 0
        for c in C:
            key += pow(2, c-1)
        keys[i] = key
    K = pow(2,N)
    dp =[10**7]*K
    dp[0] = 0
    for i in range(M):
        key = keys[i]
        cost = costs[i]
        for j in range(K):
            if j != (j | key):
                if dp[j] + cost < dp[j|key]:
                    dp[j|key] = dp[j] + cost
    if dp[K-1] == 10**7:
        print(-1)
    else:
        print(dp[K-1])
if __name__ == '__main__':
    main()


Measured memory_bytes: 45912