akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }
 
int n, cap, w, v;
ll dp[100005];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
    cin >> n >> cap;

    for (int i = 0; i < n; i++) {
        cin >> w >> v;
        for (int i = cap-w; i >= 0; i--)
            dp[i+w] = max(dp[i+w], dp[i] + v);
    }
 
    cout << dp[cap] << '\n';
 
    return 0;
}


Measured memory_bytes: 1152
import heapq


def main():
    for _ in range(M):
        mx = heapq.heappop(A) * -1 // 2 * -1
        heapq.heappush(A, mx)

    print(sum(A) * -1)


if __name__ == "__main__":
    N, M = map(int, input().split())
    A = [int(x) * -1 for x in input().split()]
    heapq.heapify(A)
    main()

Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
const int N=200006;
int n,t,p=0,cnt=0,top=0,tot=0,deep=0,a[N],f[N],v[N],s[N],num[N],sum[N],dfn[N],low[N],head[N];
bool flag=1;
struct edge{int nxt,to;}e[N<<1];
inline void add(int u,int v){e[++cnt].nxt=head[u],e[cnt].to=v,head[u]=cnt;} 
inline int read(){
  int T=0,F=1; char ch=getchar();
  while(ch<'0'||ch>'9'){if(ch=='-') F=-1; ch=getchar();}
  while(ch>='0'&&ch<='9') T=(T<<3)+(T<<1)+(ch-48),ch=getchar();
  return F*T; 
} 
void tarjan(int u){
    dfn[u]=low[u]=++deep,s[++top]=u;
    for(int i=head[u];i;i=e[i].nxt){
	    if(!dfn[e[i].to]) tarjan(e[i].to),low[u]=min(low[u],low[e[i].to]);
	    else if(!num[e[i].to]) low[u]=min(low[u],dfn[e[i].to]);
	}
	if(dfn[u]==low[u]){
	   num[u]=++tot,sum[tot]=1;
	   while(s[top]!=u) num[s[top]]=tot,++sum[tot],--top;
	   --top;
	}
}
void dfs(int x){
    for(int i=head[x];i;i=e[i].nxt) if(sum[num[e[i].to]]<=1) dfs(e[i].to);
	for(int i=head[x];i;i=e[i].nxt) if(sum[num[e[i].to]]<=1) v[f[e[i].to]]=1;
    while(v[f[x]]) ++f[x];
	for(int i=head[x];i;i=e[i].nxt) if(sum[num[e[i].to]]<=1) v[f[e[i].to]]=0;		
}
int main(){
	n=read();
	for(int i=1;i<=n;++i) t=read(),add(t,i);
	for(int i=1;i<=n;++i) if(!dfn[i]) tarjan(i);
	for(int i=1;i<=n;++i) if(sum[num[i]]>1) a[++p]=i,dfs(i);
	for(int i=2;i<=p;++i) if(f[a[i]]!=f[a[i-1]]) flag=0;
	if(flag&&(p&1)) printf("IMPOSSIBLE\n");
	else printf("POSSIBLE"); 
	return 0;
}

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

int LCS(string s, string t, int n, int m)
 {  int i,j,l[n+1][m+1];
     for( i= 0; i<=n; i++)
       {   for( j=0; j<=m; j++)
            {   if(i==0 || j==0)
                 l[i][j] = 0;
                 else if(s[i-1] == t[j-1])
                   l[i][j] = l[i-1][j-1] + 1;
                   else
                    l[i][j] = max(l[i-1][j],l[i][j-1]);

            }

       }
       string k =" ";
       i=n;
       j=m;
       while(i!=0 && j!=0)
        {   if(l[i][j] !=  max(l[i-1][j],l[i][j-1]))
              {  k = k + s[i-1];
                i--;
                j--;

              }
              else
              { if(l[i][j] == l[i][j-1])
                   {  j--;

                   }
                   else
                   { i--;


                   }



              }
        }
      if(k.length()==1)
      cout<<" ";
      else
      {  for(i=k.length()-1; i>0; i--)
            cout<<k[i];

      }



 }
int main()
{
  string s,t;
  cin>>s>>t;
  int n = s.length();
  int m = t.length();
  LCS(s,t,n,m);

  return(0);
}


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

int main(){
//int n,a[3][100000],h[3][100000];
int n;
vector<vector<int>> a(3,vector<int>(100000));
vector<vector<int>> h(3,vector<int>(100000));

//int n,a[3][3];
cin >> n;
for (int i=0;i<n;i++){
  for (int j=0;j<3;j++){
    cin >>a[j][i];
  }
}
h[0][0]=a[0][0];
h[1][0]=a[1][0];
h[2][0]=a[2][0];
for (int i=1;i<n;i++){
  h[0][i]=a[0][i]+max(h[2][i-1],h[1][i-1]);
  h[1][i]=a[1][i]+max(h[2][i-1],h[0][i-1]);
  h[2][i]=a[2][i]+max(h[1][i-1],h[0][i-1]);
  //cout <<h[0][i]<<' '<<h[1][i]<<' '<<h[2][i]<<' '<<endl;
}
cout << max(h[0][n-1],max(h[1][n-1],h[2][n-1]));
return 0;
}


Measured memory_bytes: 2936
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

int N;
long int dp[100001][3];

long int rec(int i, int a[], int b[], int c[], int abc) {
    if(i==0) return max(a[0], max(b[0], c[0]));
    if(dp[i][0]!=-1) {
        if(abc==0) return dp[i][0];
        if(abc==1) return dp[i][1];
        if(abc==2) return dp[i][2];
    }

    dp[i][0] = a[i] + max(rec(i-1, a, b, c, 1), rec(i-1, a, b, c, 2));
    dp[i][1] = b[i] + max(rec(i-1, a, b, c, 0), rec(i-1, a, b, c, 2));
    dp[i][2] = c[i] + max(rec(i-1, a, b, c, 0), rec(i-1, a, b, c, 1));

    if(abc==0) return dp[i][0];
    else if(abc==1) return dp[i][1];
    else return dp[i][2];
}

int main() {
    cin >> N;
    int a[N], b[N], c[N];
    for(int i=0; i<N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    memset(dp, -1, sizeof(dp));

    // for(int i=0; i<N; i++) {
    //     for(int j=0; j<3; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    
    long int ans;
    ans = max(rec(N-1, a, b, c, 0), max(rec(N-1, a, b, c, 1), rec(N-1, a, b, c, 2)));
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 13184
import java.util.Scanner;

public class Main {

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

    private Scanner scan = new Scanner(System.in);
    private final int N;

    public Main() {
	N = Integer.parseInt(scan.next());

	scan.close();
    }

    public final void answer() {
	System.out.println("ABC" + N);
	
    }
}


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

c, d = 4, 7

def test(n):

    if n < 4:
        return False

    if n == 4 or n == 7:
        return True
    else:
        return test(n - 4) or test(n - 7)
    
if test(N):
    print('Yes')
else:
    print('No')

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

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

    vector<int> num(3);

    int plus = a + b;
    int minus = a - b;
    int mult = a * b;
    
    num[0] = plus;
    num[1] = minus;
    num[2] = mult;

//    rep(i, 3) {
//        cout << num[i] << endl;
//    }

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

    cout << num[2] << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll now = 0;
    ll ans = 0;
    rep(i, n) {
        if (a[i] < now) {
            ans += now - a[i];
        } else {
            now = a[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4752
#include<iostream>
using namespace std;
int main(void){
  
  int N, l, r, i, sum = 0;
  
  cin >> N;
  
  for(i = 0; i < N; i++){
    
    cin >> l >> r;
    
    sum += (r - l) + 1;
    
  }
  
  cout << sum << endl;
  
  return 0;
}

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

int main(){
  int A, B;
  cin >> A >> B;
  if (A % 3 == 0 | B % 3== 0 | (A+B) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,i;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	if(a<=0){
		i=-a*c+d+b*e;
		printf("%d\n",i);
	}
	else{
	i=((b-a)*e);
	printf("%d\n",i);
	}
	return 0;
	}
	


Measured memory_bytes: 2108
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut l = read_vec::<usize>();
    l.sort();
    l.reverse();
    println!("{}", l.iter().take(k).sum::<usize>());
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
from collections import defaultdict
def main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    d = defaultdict(lambda:0)
    d2 = {}
    for i in a:
        d[i] += 1
    for i,j in d.items():
        x = j*(j-1)//2
        d2[i] = x
    ans = 0
    ans = sum(d2.values())
    for i in range(n):
        print(ans-d[a[i]]+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 34260
#include <stdio.h>
#include <stdlib.h>

#define NIL NULL

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

Node root;

void insert(int k){

  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x; 
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
 
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->left = z; 
  }
  else{
    y->right = z;
  }
}Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
  }

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

}
void preorder(Node x){

  if(x != NIL){
    printf(" %d",x->key);
    preorder(x->left);
    preorder(x->right);
  }
}

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

int main(){

  int n,i,x;
  char com[20];
  root = NIL;
  scanf("%d",&n);
 
for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
 }
 return 0;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n;
    cin >> n;
    vector<int> A(n);

    for(auto &i: A)
    	cin >> i;
    int cc=0;
    sort(A.begin(),A.end());
    FOR(i,0,n-1)
    	cc+=A[i];

    cc+=A[n-1]/2;

    cout << cc << endl;

    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
mod=10**9+7
dp=[1]*(n+1)
for i in a:
    dp[i]=0

for i in range(2,n+1):
    if dp[i] >= 1:
        dp[i]=(dp[i-1]+dp[i-2])%mod

print(dp[-1])

Measured memory_bytes: 7800
#include<bits/stdc++.h>
#define   ll    long long int
#define   sz    1000100
#define   pb    push_back
#define   py    printf("Yes\n")
#define   pn    printf("No\n")
#define   sc(a) scanf("%lld",&a)
const  double pi=acos(-1);

using namespace std;


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

int main()
{

     ll n,i,j,a,b,c,x,y,s,p,d,k;

     cin>>n;

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

     sort(num+1,num+n+1);

    ll l,h,m;
    s=0;

    for(i=1;i<=n-2;i++)
    {
        for(j=i+1;j<=n-1;j++)
        {
            a=num[i];
            b=num[j];
            d=a+b;
            l=j+1;
            h=n;
            a=-1;

            while(l<=h)
            {
                x=(l+h)/2;
                if(num[x]<d)
                {
                    a=x;
                    l=x+1;
                }
                else
                {
                    h=x-1;
                }
            }
            if(a!=-1)
            {
                s+=(a-j);
            }
        }
    }

    cout<<s<<endl;



    return 0;
}



Measured memory_bytes: 2304
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,t;
    cin >> a >> b >>t;
    int ans=0;
    for (int i = a; i <= t; i+=a){
        ans += b;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	string S,T;
	cin >> N >> S;

	if (N % 2) {
		cout << "No" << endl;
		return 0;
	}
	vector<char> A, B;
	REP(i, N / 2) {
		A.push_back(S[i]);
	}
	REP(i, N / 2) {
		B.push_back(S[i + N / 2]);
	}
	REP(i, N / 2) {
		//cout << A[i] << " " << B[i] << endl;
		if (A[i] != B[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <sstream>
using namespace std;

#define namefile ""
#define inifile freopen(namefile".inp","r",stdin); freopen(namefile".out","w",stdout)
#define fastio ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef unsigned int uint;
typedef unsigned long ulong;
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
typedef vector<int> VI;
typedef vector<long> VL;
typedef vector<string> VS;
typedef vector< VI > VVI;
typedef vector< VL > VVL;
typedef vector< PII > VPII;
typedef vector< PLL > VPLL;
typedef set<int> SETI;
typedef set<long> SETL;
typedef map<int,int> MII;
typedef map<long,long> MLL;

const long long MOD = 1e9+7;
const long long INFMAX = 1e9;
const long long INFMIN = -1e9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const double epsilon = 1e-9;
const double PI = acos(-1.00);
const int MAXN = 1e5+5;

int n,m,a[MAXN];

llong res(0);

priority_queue < int > pq;

void Input()
{
    scanf("%d %d",&n,&m);
    for (int i=1; i<=n; i++) scanf("%d",&a[i]);
}

void Solve()
{
    for (int i=1; i<=n; i++) pq.push(a[i]);
    for (int i=1; i<=m; i++)
    {
        int tmp = pq.top();
        pq.pop();
        pq.push(floor(tmp/2));
    }
    while (!pq.empty())
    {
        res += pq.top();
        pq.pop();
    }
}

void Output()
{
    printf("%lld",res);
}

int main()
{
    Input();
    Solve();
    Output();
    return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n,m,x,y,ans[3];

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> m;
	rep(3) ans[i]=-1;
	rep(m){
		cin >> x >> y;
		x--;
		if(n>1&&x==0&&y==0){
			print1(-1);
			return 0;
		}
		if(ans[x]==-1) ans[x]=y;
		if(ans[x]!=y){
			print1(-1);
			return 0;
		}
	}
	rep(n) if(ans[i]==-1) ans[i]=(n>1&&i==0?1:0);
	rep(n) cout << ans[i];
	cout << '\n';
	return 0;
}


Measured memory_bytes: 256
puts [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][gets.to_i-1]

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>

using namespace std;

int main(void)
{
        int n;
        cin >> n;
        int a[n];

        for(int i=1;i<=n;i++)
                cin >> a[i-1];
        
        sort(a,a+n);
        reverse(a,a+n);

        int pa,pb;
        pa=0;
        pb=0;

        for(int i=1;i<=n;i++)
        {
                if(i%2==1)
                        pa+=a[i-1];
                else
                        pb+=a[i-1];
        }

        cout << pa-pb << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {
  string S; cin >> S;  
  map<char, int> mp;
  rep(i, (int)S.size()) mp[S[i]]++;
  for (auto itr : mp){
    if (itr.second>1) {
      cout << "no"<<endl;
      return 0;
    }
  }
  cout <<  "yes" << endl;
}


Measured memory_bytes: 3604
use std::io;
use std::str::FromStr;
use std::cmp::max;

static MOD: i64 = 1_000_000_007;

fn input_tuple() -> (i64, i64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}


fn main() {
    let (n, k) = input_tuple();
    let a_vec = input_vec();

    if n == k {
        let mut ans = 1;
        for a in a_vec {
            ans = ans * a % MOD;
        }
        println!("{}", (MOD + ans) % MOD);
        return;
    }
    let mut a_sei: Vec<i64> = Vec::new();
    let mut a_fu: Vec<i64> = Vec::new();
    for a in a_vec {
        if a >= 0 {
            a_sei.push(a);
        } else {
            a_fu.push(a);
        }
    }
    a_sei.sort_by(|x, y| y.cmp(&x));
    a_fu.sort();
    
    if a_sei.len() == 0 && k % 2 == 1 {
        let mut ans = 1;
        for i in 0..k as usize {
            ans = ans * a_fu[a_fu.len() - 1 - i] % MOD;
        }
        println!("{}", (ans + MOD) % MOD);
        return;
    }
    let mut i = 0usize;
    while i <= k as usize {
        // println!("i = {}", i);
        if i + 1 >= a_fu.len() || k as usize - i < 2 {
            break;                
        } else if k - i as i64 - 1 >= a_sei.len() as i64 {
            i += 2;
            continue;
        } else if a_fu[i] * a_fu[i+1] > a_sei[k as usize - i - 1] * a_sei[k as usize - i - 2] {
            i += 2;
        } else {
            break;
        }
    }
    let mut ans = 1;
    // println!("{}: {}, {}", i, a_sei.len(), a_fu.len());
    for j in 0..i {
        ans *= a_fu[j as usize];
        ans %= MOD;
    }
    for j in 0..k - i as i64 {
        ans *= a_sei[j as usize];
        ans %= MOD;
    }
    println!("{}", ans);
    return;
}


Measured memory_bytes: 6216
import sys
input = sys.stdin.readline

def main():
    
    s = str(input().rstrip())
    q =int(input())
    ten = 0
    r = []
    l = []
    la = l.append
    ra =r.append
    for _ in range(q):
        ls = tuple(map(str, sys.stdin.readline().split()))
        if len(ls)==1:
            ten +=1
        else:
            if ls[1] =='1':
                if ten%2 ==0:
                    la(ls[2])
                else:
                    ra(ls[2])
            else:
                if ten%2 ==1:
                    la(ls[2])
                else:
                    ra(ls[2])
    s = ''.join(reversed(l))+s+''.join(r)
    if ten%2 ==1:
        s = s[::-1]
    print(s)
if __name__ == '__main__':
    main()

Measured memory_bytes: 94740
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


const int MOD = 1e9 + 7;


int main() {
    string s; cin >> s;
    int n_digits = s.size();

    vector<vector<long long>> dp(n_digits+1, vector<long long>(13, 0));
    dp[0][0] = 1;

    for (int i=0; i<n_digits; i++) {
        if (s[i] == '?') {
            for (int j=0; j<13; j++) {
                for (int k=0; k<10; k++) {
                    dp[i+1][((10*j)%13+k)%13] += dp[i][j];
                    dp[i+1][((10*j)%13+k)%13] %= MOD;
                }
            }
        }

        else {
            int k = s[i] - '0';
            for (int j=0; j<13; j++) {
                    dp[i+1][((10*j)%13+k)%13] += dp[i][j];
                    dp[i+1][((10*j)%13+k)%13] %= MOD;
            }
        }

        for (int j=0; j<13; j++) dp[i+1][j] %= MOD;
    }

    cout << dp[n_digits][5] << endl;
    return 0;
}



Measured memory_bytes: 13632
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {


     int n,ans=0;
      cin>>n;
         string c;
         c= to_string(n);
        for(int i=0;i<c.length();i++){
                if(c[i]=='7')
            ans++;}
            if(ans>0){
                cout<<"Yes";

            }
            else{
                cout<<"No";

            }
        }




Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main() {
    int a, b;
    string op;
    while(1) {
        cin >> a >> op >> b;
        if (op == "?") break;
        if (op == "+") {
            cout << a + b;
        } else if (op == "-") {
            cout << a - b;
        } else if (op == "*") {
            cout << a * b;
        } else {
            cout << a / b;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,k;
    cin >> n >> k;
    k+=max((10-n)*100,0LL);
    cout << k << endl;
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; ++i) {
    cin >> a[i];
  }

  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (a[i][j] == '#') {
        row[i] = true;
        col[j] = true;
      }
    }
  }

  for (int i = 0; i < H; ++i) {
    if (row[i]) {
      for (int j = 0; j < W; ++j) {
        if (col[j]) {
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
int main(){
	int N;cin>>N;
	int A[N];
	rep(i,0,N) cin>>A[i];
	int B[N]={};int total,count=0;
    deque<int> ans;
	for(int i=N;i>=1;i--){
		total=A[i-1];
		for(int j=2*i;j<=N;j+=i){
			total+=B[j-1];
		}if(total%2){ B[i-1]=1;count++;ans.push_back(i); }
	}
	cout<<count<<endl;
	print(ans,ans.size());
}

Measured memory_bytes: 3072
X, K, D = map(int, input().split())

def sign(x):
    return 1 if x >= 0 else -1


ans = abs(X) - K * D

if abs(X) - K * D < 0:
    divs = abs(X) // D
    mods = abs(X) % D
    nums = K - divs

    ans = abs(mods - (nums%2) * D)

print(ans)


# ans = min([abs(X+D*i) for i in range(-K, K+1, 2)])
# 
# print(ans)


Measured memory_bytes: 9120
import java.util.*;


import java.io.*;
 

 
 
public class Main 
{   
	
	
	public static void main(String[] args) throws IOException 
	{ 
		
		
	
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s=new StringTokenizer(br.readLine());
		
		int n=Integer.parseInt(s.nextToken());
		
		int a[]=new int[n];
		
		s=new StringTokenizer(br.readLine());
		for(int i=0;i<n;i++) {
						
			a[i]=Integer.parseInt(s.nextToken());
			
		}
		
		int min[]=new int[n];
		
		min[n-1]=a[n-1];
		for(int i=n-2;i>=0;i--) {
			min[i]=Math.min(a[i], min[i+1]);
		}
//		for(int i=0;i<n;i++) {
//			pw.println(min[i]);
//		}
		
		for(int i=0;i<a.length;i++) {
			if(a[i]-min[i]>1) {
				pw.println("No");
				pw.close();
			}
		}
		pw.println("Yes");
		pw.close();
		
		
	}

}

Measured memory_bytes: 60272
#include<bits/stdc++.h>
using namespace std;
 
#define             ll  long long
#define            ull  unsigned long long
#define            P_B  push_back
#define            M_P  make_pair
#define         DBG(x)  printf("%s %d\n", #x, x)
#define       DBGLL(x)  printf("%s %lld\n", #x, x)
#define         SCI(x)  scanf("%d",&x)
#define         SCD(x)  scanf("%lf",&x)
#define         SCS(x)  scanf("%s",x)
#define         CLR(x)  memset(x, 0, sizeof(x))
#define        CLRN(x)  memset(x, -1, sizeof(x))
#define        SCLL(x)  scanf("%lld", &x)
#define      FOR(i, n)  for(int i = 0; i < n; i++)
#define  FORR(i, m, n)  for(int i = m; i < n; i++)
#define     SCI2(m, n)  scanf("%d%d", &m, &n)
#define  SCI3(m, n, o)  scanf("%d%d%d",&m, &n, &o)
#define     SCD2(m, n)  scanf("%lf%lf",&m,&n)
#define  SCD3(m, n, o)  scanf("%lf%lf%lf",&m,&n,&o)
#define    SCLL2(m, n)  scanf("%lld%lld", &m, &n)
#define SCLL3(m, n, o)  scanf("%lld%lld%lld",&m, &n, &o)
#define             vi  vector<int>
#define            vii  vector<pair<int, int> >
#define            vll  vector<pair<ll, ll> >
#define            Mod  1000000007
#define            INF  1000000000
 

int n, m;
queue<int> st;
vi node[100001];
vector<bool> selected(100001, false);
vector<bool> visited(100001, false);
int maxxes[100001];

void topsort(int v)
{
	if(selected[v]) return;
	selected[v] = true;
	for(auto it : node[v]){
		if(!selected[it]){
			topsort(it);
		}
	}
	st.push(v);
}

int f(int v, int cnt)
{
	visited[v] = true;
	int mx =  -1;
	for(auto it : node[v]){
			mx = max(mx, maxxes[it]);
	}
	maxxes[v] = mx + 1;
	return mx + 1;
}

int main()
{
	SCI2(n, m);
	FORR(i, 1, m + 1){
		int p, q;
		SCI2(p, q);
		node[p].P_B(q);
	}
	FORR(i, 1, n + 1)topsort(i);
	int max_ = 0;
	FORR(i, 1, n + 1){
		int x = st.front();
		st.pop();
		if(!visited[x]){
			max_ = max(max_, f(x, -1));
		}
	}
	printf("%d\n", max_);
}

Measured memory_bytes: 8576
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int answer = 0;
        s = s.replace("+","");
        answer -= s.length();
        answer += 4-s.length();
        System.out.println(answer);
    }
}

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

using namespace std;

int main()
{  int a,b;
 cin>>a>>b;
   if(a==b)
   {
       cout<<"Draw"<<"\n";
   }
   else if(a==1)
   {
       cout<<"Alice"<<"\n";
   }
   else if(b==1)
   {
       cout<<"Bob"<<"\n";

   }
  else  if(a>b)
  {
      cout<<"Alice"<<"\n";
  }
  else
  {
      cout<<"Bob"<<"\n";
  }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
#define endl "\n"
#define int long long
typedef long double ld;
typedef vector<vector<int> > matrix;
typedef vector<int> arr;
typedef vector<string> vs;
typedef vector<pair<int,int> > pv;
#define test() int t;cin>>t;while(t--)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
int bx[]={0,0,1,-1,1,-1,-1,1};
int by[]={1,-1,0,0,1,-1,1,-1};
//=================================================================//

int dp[2*3001][2*3001];
int n,m;
void CommonSubsequence(int *A, int *B) {
    
    memset(dp, 0, sizeof dp);
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            if(A[i-1]==B[j-1]) {
                dp[i][j] = (1 + dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
            } else {
                dp[i][j] = (dp[i-1][j]%mod+dp[i][j-1]%mod-dp[i-1][j-1]%mod+mod)%mod;
            }
        }
    }    
}

#undef int
int main(){
#define int long long 
    fast;
    cin>>n>>m;
    int s[n], t[m];
    FOR(i,0,n-1) cin>>s[i];
    FOR(i,0,m-1) cin>>t[i];
    CommonSubsequence(s,t);
    // FOR(i,0,n) {
    //     FOR(j,0,m) cout<<dp[i][j]<<" ";
    //     cout<<endl;
    // }
    cout<<(dp[n][m]+1)%mod;
    return 0;
}

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

bool func(int sm){
  for(int i=1;i<=sm;++i){
    if(i*i==sm)return true;
  }
  return false;
}

int main(void){
  int n,d;cin >> n >> d;
  int x[n][d];rep(i,n){rep(j,d)cin >> x[i][j];}
  int ans = 0;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      int sum = 0;
      rep(k,d){
        sum += abs((x[j][k]-x[i][k])*(x[j][k]-x[i][k]));
      }
      if(func(sum)){ans += 1;}
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
parseInt(x)=parse(Int, x)
parseMap(x::Array{SubString{String},1})=map(parseInt, x)

function main()
	n,m = readline() |> split |> parseMap
	if n%2==0
		for i in m:-1:1
			if i%2==1
				println((m-i+2)>>1," ",(m-i+2)>>1+i)
			else
				println(n>>1+(m-i+2)>>1," ",n>>1+(m-i+2)>>1+i)
			end
		end
	else
		for i in m:-1:1
			if i%2==1
				println((m-i+2)>>1," ",(m-i+2)>>1+i)
			else
				println((n+1)>>1+(m-i+1)>>1," ",(n+1)>>1+(m-i+1)>>1+i)
			end
		end
	end
end

main()

Measured memory_bytes: 200812
a, b, c = map(int, input().split())

def sortBy(a, b, c):
	line = []
	taples = (a, b, c)
	line = list(taples)
	line.sort()
	return '{} {} {}'.format(line[0], line[1], line[2])

print(sortBy(a, b, c))

Measured memory_bytes: 7708
import java.util.*;
public class Main {
	static int n,a,b,c,x;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		while(true){
			n=in.nextInt();//リールの数
			a=in.nextInt();//定数
			b=in.nextInt();//定数
			c=in.nextInt();//定数
			x=in.nextInt();//乱数値
			if(n+a+b+c+x==0)break;
			int data[]= new int[n];
			for(int i=0;i<n;i++)data[i]=in.nextInt();
			int cnt=0,frame=0,ans=x;
			while(true){
				if(ans==data[frame]){
					frame++;
					x=ans;
				}
				ans=(a*ans+b)%c;
				if(cnt>10000){
					System.out.println("-1");
					break;
				}
				if(frame==n){
					System.out.println(cnt);
					break;
				}
				cnt++;
			}
		}
	}
}

Measured memory_bytes: 31704
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>  
#include <cmath>
using namespace std;


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

Measured memory_bytes: 256
import numpy as np

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

coef = np.minimum(np.arange(n, 1, -1), np.arange(1, n))
dp = np.zeros(n, dtype=np.int64)
dp[0] = 1
for c in coef:
    ndp = dp.copy()
    for i in range(c, n, c):
        ndp[i:] += dp[:n - i]
    dp = ndp % m

print((dp * np.arange(n, 0, -1) % m).sum() % m)


Measured memory_bytes: 14540
//it was hard to write
//so it should be hard to read
#include <bits/stdc++.h>
#define sz size
#define pb push_back
#define ll long long
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define last(x) (x).size() - 1
#define mp make_pair

using namespace std;

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef double ld;

const int MAXN = 3e5 + 5;
const ll INF = 1e18 + 7;
const int inf = 1e9 + 7;
const double EPS = 1e-9;

int n, sum, mx;

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.precision(9);
    cout << fixed;
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		mx = max(mx, x);
		sum += x;
	}
	sum -= mx;
	sum += (mx >> 1);
	cout << sum;
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
   // freopen("ina.txt", "r", stdin);
   // freopen("outa.txt", "w", stdout);
    string s;
    int n;
    cin >> n;
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    auto it = unique(d.begin(), d.end());
    d.resize(distance(d.begin(), it));
    cout << d.size() << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main(){
      int num;
      int a,b,c,d;
      cin >> num;
      c = num % 2;
      b = (num - c) / 10 % 2;
      d = (num-c) /10;
      a =  (d -b) / 10;
      
      cout<< a + b + c << endl;
    }

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

int main() {
  int n,ans=1; cin>>n;
  string s; cin>>s;
  char c=s[0];
  for(int i=1;i<n;i++){
    if(c!=s[i]){
      ans+=1;
    }
    c=s[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

void paint_less_x(std::vector<std::vector<int>>& P, int x, int W, int H){
    for(int i = 0; i < x; i++){
        for(int j = 0; j < H; j++){
            P.at(i).at(j) = 1;
        }
    }
}
void paint_more_x(std::vector<std::vector<int>>& P, int x, int W, int H){
    for(int i = x; i < W; i++){
        for(int j = 0; j < H; j++){
            P.at(i).at(j) = 1;
        }
    }
}
void paint_less_y(std::vector<std::vector<int>>& P, int y, int W, int H){
    for(int j = 0; j < y; j++){
        for(int i = 0; i < W; i++){
            P.at(i).at(j) = 1;
        }
    }
}
void paint_more_y(std::vector<std::vector<int>>& P, int y, int W, int H){
    for(int j = y; j < H; j++){
        for(int i = 0; i < W; i++){
            P.at(i).at(j) = 1;
        }
    }
}

int main(int argc, char **argv)
{
    int W, H, N;
    std::cin >> W >> H >> N;

    std::vector<int> x(N), y(N), a(N);

    std::vector<std::vector<int>> P(W, std::vector<int>(H, 0));
    
    for(int i = 0; i < N; i++){
        std::cin >> x.at(i) >> y.at(i) >> a.at(i);
    }

    for(int i = 0; i < N; i++){
        if(a.at(i) == 1){
            paint_less_x(P, x.at(i), W, H);
        }else if(a.at(i) == 2){
            paint_more_x(P, x.at(i), W, H);
        }else if(a.at(i) == 3){
            paint_less_y(P, y.at(i), W, H);
        }else if(a.at(i) == 4){
            paint_more_y(P, y.at(i), W, H);
        }
    }

    int ans = 0;
    for(int i = 0; i < W; i++){
        for(int j = 0; j < H; j++){
            if(P.at(i).at(j) == 0) ans++;
        }
    }

    std::cout << ans << std::endl;
}


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

int main() {
  int N;
  int sum=0;
  cin>>N;
  for(int i=0; i<N; i++){
    int l,r;
    cin>>l>>r;
    sum=sum+r-l+1;
  }
  cout<<sum<<endl;
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    char[]n = N.toCharArray();

    if(n[0]==n[1] && n[0]==n[2]){
    System.out.println("Yes");
    }else if(n[1]==n[2] && n[2]==n[3]){
    System.out.println("Yes");    
    }else{
    System.out.println("No");    
    }
}
}


Measured memory_bytes: 35468
#include<stdio.h>
int main(){
int a,b,c,d,e,i,f,g;
scanf("%d\n",&a);
for(i=0;i<a;i++){
scanf("%d %d %d %d\n",&b,&c,&d,&e);
g=b*d+c*e;
if(d>=5 && e>=2){
f=(b*d+c*e)*0.8;
}
else if(d>=5){
f=(b*d+c*2)*0.8;
if(f>g){
f=g;
}
}
else if(e>=2){
f=(b*5+c*e)*0.8;
if(f>g){
f=g;
}
}
else{
f=(b*5+c*2)*0.8;
if(f>g){
f=g;
}
}
printf("%d\n",f);
}
return 0;
}




Measured memory_bytes: 2108
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int S,W;
	scanf("%d %d",&S,&W);

	if(S <= W){

		printf("unsafe\n");

	}else{

		printf("safe\n");
	}

	return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define fi first
#define se second
#define vi vector<ll>
#define vii vector<vector<ll>>
#define pi pair<ll,ll>
#define mp make_pair
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
//freopen("explicit.in", "r", stdin);
//freopen("explicit.out", "w", stdout);
 
void SieveOfEratosthenes() 
{ 
    bool prime[10000001];
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=10000000; p++) 
    { 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (ll i=p*p; i<=10000000; i += p) {
                prime[i] = false; 
            }
        } 
    }  
} 
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
ll power(ll x,ll y,ll p) 
{ 
    ll r = 1;
  
    x = x % p;
    while (y > 0) {
        if (y & 1) 
            r = (r * x) % p;
        y = y >> 1; 
        x = (x * x) % p; 
    } 
    return r; 
}  
ll modInverse(ll n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
 
ll nCrModP(ll n,ll r, ll p) 
{ 
    ll fac[100005];
    if (r == 0) 
        return 1; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
}
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,h,b,a,k,m,maxi,d,x;
	cin>>a>>b>>c>>d;
	ll prod=-inf;
	prod=max(prod,a*c);
	prod=max(prod,a*d);
	prod=max(prod,b*c);
	prod=max(prod,b*d);
	cout<<prod;
}




	



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

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

    if (s.size() != (a + b + 1)) {
        cout << "No" << endl;
        return 0;
    }

    int cnt = 0;
    for (int i = 0; i < a; i++) {
        if(s[i] != '-') {
            cnt++;
        }
    }
    for (int i = a+1; i < s.size(); i++) {
        if (s[i] != '-') {
            cnt++;
        }
    }

    if (cnt == a + b && s[a] == '-') {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

ans = 0
if k > a:
    ans = ans + a
    k = k - a
else:
    ans = ans + k
    k = 0
if k > b:
    k = k - b
else:
    k = 0
if k > c:
    ans = ans - c
else:
    ans = ans - k
print(ans)

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

int main(){
    ll N; cin >> N;
    map<string,ll> A; //map<キー型,値型> 変数名
    rep(i,N){
        string a; cin >> a;
        sort(a.begin(),a.end());
        A[a]++;
    }
    
    ll ans=0;
    for(auto i:A){//キー値を文字列にした場合使う！
        ll x=i.second;//i.secondで値を参照できる
        ans+=x*(x-1)/2;
    }
    cout << ans;
    
    
}

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

int N,K;
// dp[i]:残りi個で勝つか負けるか
int dp[101010];

int main(){
  cin>>N>>K;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  for(int i=1;i<=K;i++) for(int a:A){
    if(i>=a && !dp[i-a]) dp[i]=1;
  }
  cout<<(dp[K]?"First":"Second")<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <numeric>
#include <array>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	const int Max = 100;
	int N;
	cin >> N;
	struct Data {
		int ex_pos; //番号
		int point;	//点数
		string name;
	};

	vector<Data> d(N); //vectorの中に構造体(型) 宣言時にサイズは指定しておく

	for (int i = 0; i < N; i++) {
		d[i].ex_pos = i;
		cin >> d[i].name >> d[i].point;
	}
	sort(d.begin(), d.end(), [](const Data& x, const Data& y) {if (x.name == y.name) { return x.point > y.point; }
	return x.name < y.name; }
	);
		//(始点,終点, )
			//cout << d;
	for (int j = 0; j < N; j++) {
		cout << d[j].ex_pos + 1 << endl;
	}

	; return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()

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

ans = -float("inf")

left = v[:]
right = v[::-1]

import bisect

for i in range(n + 1):
    for j in range(n + 1 - i):
        if i + j > k:
            continue
        left_and_right = left[:i] + right[:j]
        left_and_right.sort()
        cnt = k - (i + j)
        idx = bisect.bisect_left(left_and_right, 0)
        minus = sum(left_and_right[:min(cnt, idx)])
        ans = max(sum(left_and_right) - minus, ans)

print(ans)



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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
#define X first
#define Y second
#define pb push_back

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fout << vec[i] << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr ll INF = numeric_limits<ll>::max();
constexpr ll MOD = 1e9 + 7;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll a, b; cin >> a >> b;
    vector<string> v(100);
    string p;
    for (ll i = 0; i < 50; i++) p += '.';
    for (ll i = 0; i < 50; i++) p += '#';
    for (ll i = 0; i < 100; i++) v[i] = p;

    ll x = 1, y = 51;
    for (ll i = 1; i < a; i++) {
        v[x][y] = '.';
        y += 2; if (y >= 99) { x += 2; y = 51; }
    }

    x = 1; y = 1;
    for (ll i = 1; i < b; i++) {
        v[x][y] = '#';
        y += 2; if (y >= 48) { x += 2; y = 1; }
    }

    cout << 100 << " " << 100 << "\n";
    for (ll i = 0; i < 100; i++) cout << v[i] << "\n";
    return 0;
}


Measured memory_bytes: 256
let () =
  let rec main_loop () =
    let n = read_int () in
    if n = 0 then ()
    else begin
      let rec doit i ans sum =
        if i = n then ans
        else
          let a = read_int () in
          let sum = if sum < 0 then a else sum + a in
          doit (i + 1) (max ans sum) sum in
      doit 0 min_int 0 |> Printf.printf "%d\n";
      main_loop ()
    end in
  main_loop ()

Measured memory_bytes: 2548
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int A,B;
    cin>>A>>B;
    int result=-1;
    int A_min=ceil(A/(0.08));
    int B_min=ceil(B/(0.1));
    
    float A_max=(A+1)/0.08;
    float B_max=(B+1)/(0.1);
    bool flag=false;
    int i=A_min;
    int j=B_min;
    while(true){
    
        if(i<A_max&&j<B_max){
            if(i>j){
                j++;
            }else if(i<j){
                i++;
            }else{
                result=i;
                break;
            }
        }else{
            break;
        }
    }
    cout<<result;


}

Measured memory_bytes: 256