akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(a>b)a--;
  cout << a << endl;
}


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

int getDay(int y,int m,int d){
	if(m<3) m += 12 , y--;
	int J = y/100 , K = y%100;
	return (d + (((m+1)*26)/10) + K + (K/4) + (J/4) + 5*J) % 7;
}
int main(){
	string table[] = {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
	int m,d;
	while(cin >> m >> d , m){
		cout << table[getDay(2004,m,d)] << endl;
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
using namespace std;

#define lint long long int
#define INF 99999999

bool buy[13];
int n,m,x,c[13],a[13][13],min_money=INF;


void dfs (int pos)
{
    for (int i = 0; i < 2; i++) {
        if (i) buy[pos] = true;
        else buy[pos] = false;
        
        if (pos == n) {
            int val[13], money=0;
            for (int k = 1; k <= m; k++) val[k] = 0;
            
            for (int j = 1; j <= n; j++) {
                if (buy[j]) {
                    money += c[j];
                    for (int k = 1; k <= m; k++) val[k] += a[j][k];
                }
            }
            
        
            bool possible = true;
            for (int k = 1; k <= m; k++) {
                if (val[k] < x) {
                    possible = false;
                    break;
                }
            }
            if (possible) {min_money = min(min_money, money);}
        }
        else dfs(pos+1);
    }
}


int main()
{
    cin >> n >> m >> x;
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
        for (int j = 1; j <= m; j++) cin >> a[i][j];
    }
    
    dfs(1);
    if (min_money == INF) cout << -1;
    else cout << min_money;
    cout << endl;
}





Measured memory_bytes: 3636
n,m=map(int,input().split())
lis=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))
s=0
for i in range(2**n):
  ok=True
  for k in range(m):
    cnt=0
    for j in range(n):
      if (i>>j)&1:
        if j+1 in lis[k][1:]:
          cnt+=1
    if cnt%2!=p[k]:
      ok=False
  if ok:
    s+=1
print(s)

Measured memory_bytes: 3064
N = int(input())
c = input()
l = 0
r = N-1
cnt = 0
while(l<r):
    if c[l] == "W" and c[r] == "R":
        cnt += 1
        l += 1
        r -= 1
    elif c[l] == "R":
        l += 1
    elif c[r] == "W":
        r -= 1
print(cnt)

Measured memory_bytes: 67496
import java.util.*;

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

    public static void main(String[] args) {
        List<Integer> ans = new ArrayList<>();
        int n = 0;
        do {
            n = input.nextInt();
            int[] arr = new int[n];

            for (int i = 0; i < n ; i ++) {
                arr[i] = input.nextInt();
            }

            Arrays.sort(arr);

            int sum = 0;
            for (int i= 1; i < n-1; i ++) {

                sum += arr[i];
            }

            int result = sum / (n -2);
            ans.add(result);
        } while (n > 0);

        for (int i = 0; i < ans.size() -1; i ++) {
            System.out.println(ans.get(i));
        }
    }
}


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

int main(){
  int s; cin >> s;
  int hour = s / 3600;
  s %= 3600;
  int min = s / 60;
  s %= 60;

  cout << hour << ":" << min << ":" << s << endl;

  return 0;
}


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

//g++ -g -o yourexe yourfile.cpp
//./yourexe < yourinput.in > youroutput.out

#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define M 201

#define ll long long
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vii vector<pi>
#define vvi vector<vi>
#define pb push_back
#define endl "\n"

#define REP(i, s, e) for (ll i = s; i < e; i++)
#define RREP(i, s, e) for (ll i = s; i > e; i--)

#define all(v) v.begin(), v.end()
#define print(v) for (auto i: v) cout << i << " ";

int main() {
    fast
    ld a, b, x;
    cin >> a >> b >> x;
    ld t = (b*a*a)/2.0, sl, an;
    if (x > t) {
        sl = 2.0*(b/a - x/(a*a*a));
        an = atan(sl);
    }
    else {
        sl = (b*b*a)/(2.0*x);
        an = atan(sl);
    }
    cout << fixed << setprecision(32) << an * 180 / 3.141592 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iomanip>

using namespace std;

char s[200000];
int a[200000],b[200000];
int n,k,t1,t2;

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n>>k;
	int i,j;
	t1=0;
	t2=0;
	scanf("%s",s);
	if(s[0]=='1'){
		for(i=0;i<n;){
			j=i;
			while(s[j]==s[i]&&j<n)j++;
			if(s[i]=='1')a[++t1]=j-i;
			else b[++t2]=j-i;
			i=j;
		}
		if(t2<=k){
			cout<<n<<endl;return 0;
		}
		b[t2+1]=0; a[t1+1]=0;
		int sum = 0;
		int ans=0;
		for(i=1;i<=t2;i++)b[i]+=a[i];
		for(i=1;i<=k;i++)sum+=b[i];
		ans = sum + a[k+1];
		i=1;j=k+1;
		while(j<n){
			sum+=b[j];
			sum-=b[i];
			j++;i++;
			if(sum+a[j]>ans)ans=sum+a[j];
		}
		cout<<ans<<endl;
	}
	else{
		//cout<<111<<endl;
		for(i=0;i<n;){
			j=i;
			while(s[j]==s[i]&&j<n)j++;
			if(s[i]=='1')a[++t1]=j-i;
			else b[++t2]=j-i;
			//cout<<i<<' '<<j<<endl;
			//cout<<j-i+1<<endl;;
			i=j;
		}
		if(t2<=k){
			cout<<n<<endl;return 0;
		}
		//for(i=1;i<=t1;i++)cout<<a[i]<<endl;
		//cout<<endl;
		//for(i=1;i<=t2;i++)cout<<b[i]<<endl;
		//cout<<endl;		
		b[t2+1]=0; a[t1+1]=0;
		int sum = 0;
		int ans=0;
		a[0]=0;
		for(i=1;i<=t2;i++)b[i]+=a[i-1];
		for(i=2;i<=k+1;i++)sum+=b[i];
		ans = sum + a[k+1];
		i=2;j=k+2;
		while(j<n){
			sum+=b[j];
			sum-=b[i];
			j++;i++;
			if(sum+a[j-1]>ans)ans=sum+a[j-1];
		}
		sum=0;
		for(i=1;i<=k;i++)sum+=b[i];
		sum+=a[k];
		if(ans<sum)ans=sum;
		cout<<ans<<endl;		
		
	}
	
	
	
	return 0;
}


Measured memory_bytes: 768
#include<stdio.h>
int main(void)
{
 char s[4];
 int i,count=0,sum=0,fa=0,fb=0,fc=0;
 scanf("%s",s);
  
 while(s[count]!='\0')
 {
  if(fa==0)if(s[count]=='a'){sum++;fa++;}
  if(fb==0)if(s[count]=='b'){sum++;fb++;}
  if(fc==0)if(s[count]=='c'){sum++;fc++;}
   
   count++;
 }

 if(sum==3) printf("Yes");
 else printf("No");
 return 0;
}

Measured memory_bytes: 128
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

ans = 0 
for a in A:
    c = C
    for i, j in zip(a, B):
        c += i*j
    if c > 0:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
void myInit();
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int MOD = 1000000007;
const int N = 3e5, M = N;
//=========TQR==============
vi g[N];
int a[N];

int main() {
	myInit();
	FIO;
	int a[5];
	for (int i = 0; i < 5; i++)
		cin >> a[i];
	for (int i = 0; i < 5; i++) {
		if (a[i] == 0) {
			cout << i + 1 << endl;
			break;
		}
	}
	return 0;
}

void myInit() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mpow(int base, int exp) {
	base %= MOD;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % MOD;
		base = ((ll)base * base) % MOD;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10612
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
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")
}


//main function
fn main() {
    let a:i64 = read();
    let b:i64 = read();
    let c:i64 = read();
    if a <b {
	if b < c{
	    println!("{}",a*b/2);
	}else{
	    println!("{}",a*c/2);
	}
    }else {
	if a < c{
	    println!("{}",a*b/2);
	}else {
	    println!("{}",b*c/2);
	}
    }
}


Measured memory_bytes: 4352
n, w = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(n)]

# dp[i][j] := i番目の以前の品物から、重さがj以下になるような最大の価値
dp = [[-1]*(w+1) for _ in range(n+1)]
for i in range(w+1):
    dp[0][i] = 0

for i in range(1, n+1):
    for j in range(w+1):
        # 重さjより上なら、選ばない
        if j < a[i-1][0]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-a[i-1][0]] + a[i-1][1])
            
print(dp[n][w])

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

const int dx[] = {0, 1, -1, 1, -1, 0};
const int dy[] = {1, 1, 0, 0, -1, -1};
int t, n;
int d[222][222];
int can[222][222];
int x, y;
int N = 70;

int main()
{
  while(cin >> t >> n, t){
    rep(i, 222) rep(j, 222) d[i][j] = 0;
    rep(i, 222) rep(j, 222) can[i][j] = INF;
    rep(i, n){
      cin >> x >> y;
      can[x+N][y+N] = -INF;
    }
    cin >> x >> y;

   queue<pair<pii, int> > que;
   can[x+N][y+N] = false;
   d[x+N][y+N] = 1;
   que.push(mp(mp(x, y), 0));
   while(!que.empty()){
     pair<pii, int> here = que.front();  que.pop();
     int hx = here.first.first;
     int hy = here.first.second;
     int cnt = here.second;
     if(cnt >= t) continue;
     rep(k, 6){
       int nx = hx + dx[k];
       int ny = hy + dy[k];
       if(minup(can[nx+N][ny+N], cnt + 1)){
         d[nx+N][ny+N] = 1;
         que.push(mp(mp(nx, ny), cnt + 1));
       }
     }
   }

   int res = 0;
   rep(i, 222) rep(j, 222) res += d[i][j];

   cout << res << endl;
  }

  return 0;
}

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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main (){

    ll A,B,C,X,Y,tmp=0,ans=0,d=0;
    cin >> A >> B >> C >> X >> Y;
    
    tmp = X-Y;
    d = min(A+B,2*C);
    ans += min(X,Y) * d;
    if(tmp > 0) {
        ans += tmp*min(A,C*2);
    }else if(tmp < 0) {
        ans += abs(tmp)*min(B,C*2);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
use proconio::marker::*;
use std::collections::*;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;
const MOD: i64 = 1_000_000_007;
fn main() {
    input! {
        N:usize,S:Chars
    }
    let mut ans = 0;
    let mut T = vec![0; N];
    let (mut R, mut G, mut B) = (0i64, 0i64, 0i64);
    for i in 0..N {
        T[i] = match S[i] {
            'R' => {
                R += 1;
                1
            }
            'G' => {
                G += 1;
                2
            }
            'B' => {
                B += 1;
                4
            }
            _ => 0,
        };
    }
    ans = R * G * B;
    for i in 0..N {
        for j in i + 1..N {
            let k = j + j - i;
            if k >= N {
                break;
            }
            if T[i] + T[j] + T[k] == 7 {
                ans -= 1;
            }
        }
    }

    println!("{}", ans);
}


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

int main(){
    string s;
    cin >> s;
    int n;
    n=s.length();
    int i=0;int j=0;
    while(i<=n){
        ++j;
        if(s[i]=='A') break;
        ++i;
    }
    i=n-1;int k=0;
    while(i>=0){
        ++k;
        if(s[i]=='Z') break;
        --i;
    }
    cout << (n-k+1)-j+1 << endl;
}

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

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long

#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

int main()
{
	fastIO;
	ll a,b,c,ans=1;
	cin>>a>>b>>c;
	if(a!=b or b!=c or c!=a)ans=0;
	if(ans==0)cout<<"No";else cout<<"Yes";
}

	

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

int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    long ans;
    if(x>=y){
        ans=y*min(a+b,c*2)+(x-y)*min(a,c*2);
    }
    else{
        ans=x*min(a+b,c*2)+(y-x)*min(b,c*2);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
#define N 100
 
void Tr(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}
 
int main(void){
  int A[N+1],i,j,key,n,count=0,sm,cou;
  scanf("%d",&n);
  for(i=1 ; i<n+1 ; i++){
      scanf("%d",&A[i]);
    }
  for(i=0 ; i<=n ; i++){
      sm = i;
      cou=0;
      for(j=i ; j<=n ; j++){
      if(A[j] < A[sm]){
          sm = j;
          cou=1;
        }
    }
      if(cou==1){
      key = A[i];
      A[i] = A[sm];
      A[sm] = key;
      count++;
      }
  }
  Tr(A, n);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    int A, B;
    int a, b, c, d;
    int x;
    int cnt = 0;
    cin >> A >> B;
    for (int i = A; i <= B;i++){
        a = i / 10000;
        x = i % 10000;
        b = x / 1000;
        x %= 100;
        c = x / 10;
        d = x % 10;
        if (a == d && b == c)
            cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;

int main(){
    int n,a, suma = 0;
    vector<int> x;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        x.push_back(a);
    }
    sort(x.begin(),x.end());
    for (int i = 0; i < n; i++){
        if (i % 2) suma-= x[i];
        else suma += x[i];
        
    }
    
    cout << abs(suma);
    return 0;

}

Measured memory_bytes: 256
N,W=map(int,input().split())
w=[]
v=[]
for i in range(N):
  w_,v_=map(int,input().split())
  w.append(w_)
  v.append(v_)
  
dp=[[0]*(W+1) for i in range(N+1)]
for i in range(N):
  for j in range(W+1):
    dp[i+1][j]=max(dp[i+1][j],dp[i][j])
    if j+w[i] <=W:
      dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i])

print(dp[N][W])
#print(dp)

Measured memory_bytes: 120172
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	str := sc.Text()
	sc.Scan()
	q, _ := strconv.Atoi(sc.Text())
	for i := 0; i < q; i++ {
		sc.Scan()
		switch order := sc.Text(); order {
		case "print":
			sc.Scan()
			a, _ := strconv.Atoi(sc.Text())
			sc.Scan()
			b, _ := strconv.Atoi(sc.Text())
			fmt.Println(str[a : b+1])
		case "reverse":
			sc.Scan()
			a, _ := strconv.Atoi(sc.Text())
			sc.Scan()
			b, _ := strconv.Atoi(sc.Text())
			runes := []rune(str)
			for i, j := a, b; i < j; i, j = i+1, j-1 {
				runes[i], runes[j] = runes[j], runes[i]
			}
			str = string(runes)
		case "replace":
			sc.Scan()
			a, _ := strconv.Atoi(sc.Text())
			sc.Scan()
			b, _ := strconv.Atoi(sc.Text())
			sc.Scan()
			p := sc.Text()
			str = str[:a] + p + str[b+1:]
		}
	}
	return
}



Measured memory_bytes: 1328
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n,q;
  int minq = 0;
  string ans = "kogakubu10gokan";
  cin >> n >> q;
  for(int i = 0;i < n;i++){
    int a;string s;
    cin >> a >> s;
    if(minq < a && q >= a ){
      minq = a;
      ans = s;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3212
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 100000001


int main(){

int a,b,c;
scanf("%d %d %d",&a,&b,&c);

if(a+b+c!=17)
    printf("NO");
else
    printf("YES");

}


Measured memory_bytes: 128
//om namah shivaaay//
#include <bits/stdc++.h>
#define input int t;cin>>t;while(t--)
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout.precision(10)
 #define ll long long
 #define vi  vector<int>vec
 #define pb push_back
 #define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
 #define f(i, a, b) for (int i = 0; i < (b); i++)
 #define w(t) int t;cin>>t;while(t --)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
 const int N=1e5 +5;
 using namespace std;
 int main()
 {
    Om_namah_Shivaay;
    int x;
    cin>>x;
    if(x>=30)
     cout<<"Yes"<<endl;
     else
     cout<<"No"<<endl;
 }


Measured memory_bytes: 3624
import Data.List
main=do
 n<-readLn
 s<-words<$>getLine
 let a=sortOn(negate.length).group.sort$[x|(i,x)<-zip[0..]s,even i]
 let b=sortOn(negate.length).group.sort$[x|(i,x)<-zip[0..]s,odd i]
 let u=length$a!!0
 let v=length$b!!0
 print.minimum$[n-(if a!!0!!0/=b!!0!!0 then u+v else 0),n-u-if 1<length b then length$b!!1 else 0,n-v-if 1<length a then length$a!!1 else 0]

Measured memory_bytes: 54652
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

constexpr const int N_MAX = 100010;
constexpr const int sqrtN = 200;

int N, K;
int a[N_MAX];
int b[N_MAX / sqrtN + 1];

void build()
{
  for (int i = 0; i < K; ++i) {
    const int s = i * sqrtN;
    const int t = s + sqrtN;
    for (int j = s; j < t; ++j) {
      b[i] = __gcd(b[i], a[i]);
    }
  }
}

int query(int l, int r)
{
  int ret = 0;
  while(l < r && l % sqrtN != 0) ret = __gcd(ret, a[l++]);
  while(l < r && r % sqrtN != 0) ret = __gcd(a[--r], ret);

  for (int i = l/sqrtN; i < r/sqrtN; ++i) {
    ret = __gcd(ret, b[i]);
  }

  return ret;
}

signed main()
{
  iostreamBooster();

  cin >> N;
  K = (N + sqrtN - 1) / sqrtN;

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

  build();

  int maxv = 0;
  for (int i = 1; i <= N; ++i) {
    chmax(
        maxv,
        __gcd(query(1, i), query(i+1, N+1))
    );
  }

  cout << maxv << endl;


  return 0;
}



Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
X = [0] * (10**5)

for i in range(N):
    X[A[i]-1] += 1

ans = sum(A)

for j in range(Q):
    b, c = map(int, input().split())
    a = X[b-1]
    X[b-1] = 0
    X[c-1] += a
    ans = ans - a*b + c*a
    print(ans)

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

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
    sort(d.begin(), d.end());

    int ans = d[n / 2] - d[n / 2 - 1];

    cout << ans << endl;
    
    return 0;
}


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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }			//最小公倍数(Least Common Multiple)


int main() {
	int a, b, m;
	cin >> a >> b >> m;
	vector<lli>	va(a);
	vector<lli>	vb(b);
	rep(i, a)	cin >> va[i];
	rep(i, b)	cin >> vb[i];

	vector<lli> x(m);
	vector<lli> y(m);
	vector<lli> c(m);
	rep(i, m)	cin >> x[i] >> y[i] >> c[i];

//	vector<vector<int>>	vc(b, vector<int> (a));
//	rep(i, m) {
//		vc[x[i]-1][y[i]-1] = c[i];
//	}

	vector<lli>::iterator itra = min_element(va.begin(), va.end());
	lli minindexa = distance(va.begin(), itra);
	vector<lli>::iterator itrb = min_element(vb.begin(), vb.end());
	lli minindexb = distance(vb.begin(), itrb);

	lli ans = va[minindexa] + vb[minindexb];

	rep(i, m) {
		ans =min(ans,va[x[i] - 1] + vb[y[i] - 1] - c[i]);
	}

	cout << ans << endl;




}

Measured memory_bytes: 4224
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string.h>
#include<algorithm>

int main() {

	int N, M;
	int K[100];
	int A[40][40];
	int cnt[40];
	int ans = 0;

	scanf("%d %d", &N, &M);

	for (int i = 0; i < N; i++) {
		scanf("%d", &K[i]);
		for (int j = 0; j < K[i]; j++) {
			scanf("%d", &A[i][j]);
		}
	}

	for (int i = 0; i < M + 1; i++) {
		cnt[i] = 0;
	}


	for (int i = 0; i < N; i++) {
		for (int j = 0; j < K[i]; j++) {
			cnt[A[i][j]]++;
		}
	}

	for (int i = 1; i < M + 1; i++) {
		if (cnt[i] == N)ans++;
		//printf("%d %d \n", i, cnt[i]);
	}
	printf("%d", ans);

	return(0);
}

Measured memory_bytes: 128
#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 x;
  rep(i, 5){
    cin >> x;
    if (x == 0){
      cout << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=4e5+5;
ll a[N];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int d,n,cnt=0;
    cin >>d>>n;
    if(d==0){
        if(n<=99)   cout <<n <<endl;
        else    cout<<101<<endl;
        return 0;
    }
    else if(d==1){
        if(n<=99)   cout << n <<"00"<<endl;
        else cout<<"10100"<<endl;
    }
    else{
        if(n<=99)   cout<< n <<"0000"<<endl;
        else    cout<<"1010000"<<endl;
    }


    return 0;
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int a,b;

int main(){
  scanf("%d %d",&a,&b);
  int cnt = 0;
  FOR(i,a,b+1){
    stringstream ss;
    ss << i;
    string s = ss.str();
    string k = ss.str();
    reverse(k.begin(),k.end());
    if(s==k) cnt++;
  }
  printf("%d\n",cnt);
}


Measured memory_bytes: 256
#include <stdio.h>
int MAX(int a,int b){
    return a>=b?a:b;
}
int main()
{   int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    printf("%d",MAX(a*b,c*d));

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct SegTree {
  int size;
  vector<ll> pos;
  SegTree(ll N) { size = 1; while(size<N) size<<=1; pos.resize(2*size,0); }
  ll operator[](const ll &x) const { return pos[x+size]; }

  void build() { per(i,size) operate(i); }
  void set(ll x, const ll v) { pos[x+size] = v; }
  void update(ll x, const ll v) { set(x,v); x+=size; while (x>>=1) operate(x); }
  ll query(ll a, ll b) {
    ll L = 0, R = 0;
    for (a+=size, b+=size; a<b; a>>=1, b>>=1) {
      if (a&1) { L = q(L,pos[a]); a++; }
      if (b&1) { b--; R = q(R,pos[b]); }
    }
    return q(L,R);
  }
  void operate(ll i) { pos[i] = (pos[i*2] + pos[i*2+1])%MOD; }
  ll q(ll x, ll y) { return (x + y)%MOD; }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N, A, B; cin >> N >> A >> B; if (A>B) swap(A,B);
  ll S[N+1] = {}; rep(i,N) cin >> S[i+1]; S[0] = -1*LLINF;

  rep(i,N-1) {
    if (S[i+2]-S[i]<A) {
      cout << 0 <<endl;
      return 0;
    }
  }

  SegTree st(N+1); st.update(0,1);
  ll pz = -1;
  rep(i,N) {
    ll p = upper_bound(S,S+(N+1),S[i+1]-B) - S;
    st.update(i+1,st.query(pz+1,p));
    if (S[i+1]-S[i]<A) pz = i-1;
    // cout << pz+1 << "~" << p << endl;
    // rep(j,i+2) cout << st[j] << " "; cout << endl;
  }
  ll result = st.query(pz+1,N+1);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int>> Graph;

int main() {
    int a,b;
    cin >> a >> b;
    if(a<=8&&b<=8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxd = 1e5+10;
long long ans;
int n,k,m,fa[maxd<<1],a[maxd<<1][2];
int gf(int x)
{
    if(fa[x] == x) return x;
    return fa[x] = gf(fa[x]);
}
int main()
{
    // freopen("a.in","r",stdin);
    // freopen("k.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<(maxd<<1);i++) fa[i] = i;
    for(int i=1;i<=n;i++)
    {
        int x,y; scanf("%d %d",&x,&y);
        fa[gf(x)] = gf(y+maxd);
    }
    for(int i=1;i<(maxd<<1);i++) a[gf(i)][(i >= maxd)]++;
    for(int i=1;i<(maxd<<1);i++) ans += 1ll * a[i][0] * a[i][1];
    printf("%lld",ans - n);
    return 0;
}

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

namespace CSharpSample01
{


    class Program
    {
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] data = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            long all = 0;
            var sa1 = new int[N];
            var sa2 = new int[N];
            for(int i = 0; i < N; i++)
            {
                if(i <= N - 2) all += Math.Abs(data[i + 1] - data[i]);
                if(i == 0)
                {
                    sa1[i] = Math.Abs(data[i + 1] - data[i]) + Math.Abs(data[i]);
                    sa2[i] = Math.Abs(data[i + 1]);
                }
                else if(i == N - 1)
                {
                    sa1[i] = Math.Abs(0 - data[i]) + Math.Abs(data[i] - data[i - 1]);
                    sa2[i] = Math.Abs(0 - data[i - 1]);
                }
                else
                {
                    sa1[i] = Math.Abs(data[i] - data[i - 1]) + Math.Abs(data[i + 1] - data[i]);
                    sa2[i] = Math.Abs(data[i + 1] - data[i - 1]);
                }
            }

            all += Math.Abs(data[0]) + Math.Abs(data[N - 1]);

            //Console.WriteLine("all = " + all);

            for(int i = 0; i < N; i++)
            {
                Console.WriteLine(all - (sa1[i] - sa2[i]));
            }         

        }
    }
}

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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string s;
    cin >> s;

    int cnt[4] = {};
    map<char, int> m{{'N', 0}, {'S', 1}, {'W', 2}, {'E', 3}};
    for (int i = 0; i < s.length(); i++)
    {
        cnt[m[s[i]]] = 1;
    }

    if ((cnt[0] ^ cnt[1]) || (cnt[2] ^ cnt[3]))
    {
        // cout << (cnt[0] ^ cnt[1]) << "," << (cnt[2] ^ cnt[3]) << endl;
        cout << "No" << endl;
    }
    else
        cout << "Yes" << endl;
}

Measured memory_bytes: 256
use itertools::{iproduct, Itertools};
use proconio::input;

fn main() {
    unsafe {
        input!(n: usize, k: usize, ijc: [(usize, usize, char); n]);
        let mut g = [[0; 1001]; 1001];
        let mut b_count = 0;
        let mut w_count = 0;
        for &(i, j, c) in &ijc {
            *g.get_unchecked_mut(i % k + 1).get_unchecked_mut(j % k + 1) +=
                if ((i / k + j / k) % 2 == 1) ^ (c == 'W') {
                    w_count += 1;
                    1
                } else {
                    b_count += 1;
                    -1
                };
        }
        for (i, j) in iproduct!(0..k, 0..k) {
            *g.get_unchecked_mut(i + 1).get_unchecked_mut(j + 1) +=
                g.get_unchecked(i + 1).get_unchecked(j) + g.get_unchecked(i).get_unchecked(j + 1)
                    - g.get_unchecked(i).get_unchecked(j);
        }

        let (min, max): (i32, i32) = iproduct!(0..k, 0..k)
            .map(|(i, j)| {
                g.get_unchecked(k).get_unchecked(k)
                    - g.get_unchecked(i).get_unchecked(k)
                    - g.get_unchecked(k).get_unchecked(j)
                    + 2 * g.get_unchecked(i).get_unchecked(j)
            })
            .minmax()
            .into_option()
            .unwrap();
        println!("{}", std::cmp::max(-min + w_count, max + b_count));
    }
}


Measured memory_bytes: 10372
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);
    
    double a,b,c,d,e,f,x,y;
    while(scan.hasNextDouble()){
    a = scan.nextDouble();
    b = scan.nextDouble();
    c = scan.nextDouble();
    d = scan.nextDouble();
    e = scan.nextDouble();
    f = scan.nextDouble();
    y = (d*c - a*f)/(d*b - a*e);
    x = (c-b*y)/a;
    System.out.printf("%.3f %.3f\n",x,y);
    }
    }
}

Measured memory_bytes: 28188
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 3e5 + 5;

vector<pi> targets;
vector<vector<int>> row(MAXN), col(MAXN);

int row_cnt[MAXN], col_cnt[MAXN];
int rt[4 * MAXN], ct[4 * MAXN];

void build(int v, int tl, int tr, int arr[], int t[])
{
    if(tl == tr)
        t[v] = arr[tl];
    else
    {
        int tm = (tl + tr) >> 1;
        build(v << 1, tl, tm, arr, t);
        build(v << 1 | 1, tm + 1, tr, arr, t);
        t[v] = max(t[v << 1], t[v << 1 | 1]);
    }
}

void update(int v, int tl, int tr, int pos, int add, int t[])
{
    if(tl == tr)
        t[v] += add;
    else
    {
        int tm = (tl + tr) >> 1;
        if(pos <= tm)
            update(v << 1, tl, tm, pos, add, t);
        else
            update(v << 1 | 1, tm + 1, tr, pos, add, t);
        t[v] = max(t[v << 1], t[v << 1 | 1]);
    }
}

void cp()
{
    int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0; i < k; i++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        targets.pb({u, v});
        row[u].pb(i);
        col[v].pb(i);
        row_cnt[u]++;
        col_cnt[v]++;
    }

    build(1, 0, n - 1, row_cnt, rt);
    build(1, 0, m - 1, col_cnt, ct);

    int ans = 0;

    for(int i = 0; i < n; i++)
    {
        // take the ith row
        int me = row_cnt[i];
        // remove all targets in row i
        for(int x : row[i])
        {
            int c = targets[x].ss;
            // remove 1 from this col
            update(1, 0, m - 1, c, -1, ct);
        }
        // take max
        int best = ct[1];

        me += best;
        ans = max(ans, me);
        // add the targets back
        for(int x : row[i])
        {
            int c = targets[x].ss;
            // add 1 to this col
            update(1, 0, m - 1, c, 1, ct);
        }
    }

    for(int i = 0; i < m; i++)
    {
        // take the ith col
        int me = col_cnt[i];
        // remove all targets in col i
        for(int x : col[i])
        {
            int r = targets[x].ff;
            // remove 1 from this row
            update(1, 0, n - 1, r, -1, rt);
        }
        // take max
        int best = rt[1];
        me += best;
        ans = max(ans, me);
        // add the targets back
        for(int x : col[i])
        {
            int r = targets[x].ff;
            // add 1 to this row
            update(1, 0, n - 1, r, 1, rt);
        }
    }
    cout << ans;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 48984
#include <iostream>
#include <string>
using namespace std;
#define MAX 100005
#define min(x,y) ((x)<(y))?x:y
int main()
{
	long N, A[MAX], B[MAX];
	string judge = "Yes";
	cin >> N;
	for (int i = 0; i <= N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> B[i];

	
	long tmpii = min(A[0], B[0]);
	long tmpii_1 = min(A[1], B[0] - tmpii);
	long sum = tmpii + tmpii_1;
	for (int i = 1; i < N; i++) {
		tmpii = min(A[i] - tmpii_1, B[i]);
		sum += tmpii;
		tmpii_1 = min(A[i + 1], B[i] - tmpii);
		sum += tmpii_1;
		
	}
	cout << sum << endl;

}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
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;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int n,m,i,j;
	cin>>n>>m;
	int syu[m]={0};
	for(i=0;i<n;i++){
		int num,tmp;
		cin>>num;
		for(j=0;j<num;j++){
			cin>>tmp;
			syu[--tmp]++;
		}
	}
	int ans=0;
	for(i=0;i<m;i++)if(syu[i]==n)ans++;
	cout<<ans<<endl;
	
	
	
	
	
	
	return 0;
}

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

int main(){
  int n,i,kotae=0,a=0;
  cin>>n;
  char c;
  for(i=0;i<n;i++){
    cin>>c;
    if(c=='A'){
      a=1;
    }else if(c=='B'&&a==1){
      a=2;
    }else if(c=='C'&&a==2){
      kotae++;
      a=0;
    }else{
      a=0;
    }
  }
  cout<<kotae;
}


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

#define ll long long
#define F(i,a,b) for(int i=a;i<=b;++i)
#define R(i,a,b) for(int i=a;i<b;++i)
#define mem(a,b) memset(a,b,sizeof(a))

int n, k;
int a[100100], b[100100];
ll ans, ret;
int c;
int main()
{
	cin >> n >> k;
	F(i, 1, n) scanf("%d %d", a + i, b + i);
	ans = 0;
	F(i, 1, n)
	{
		if ((a[i] | k) == k) ans += b[i];
	}
	F(i, 0, 30)if ((1 << i)&k)
	{
		c = (k - (1 << i)) | ((1 << i) - 1);
		ll ret = 0;
		F(j, 1, n) if ((c | a[j]) == c) ret += b[j];
		ans = max(ans, ret);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
/*
Thank you for helping me out Endagorion
You have really been an inspiration
I will prove my worth to you
i will return in APRIL

"May God help me in this venture of mine"

*/


#include <iostream>
#include <sstream>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <queue>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>

using namespace std;

#define endl '\n'
#define lli long long int
#define USE_MATH_DEFINES
const long INF = 100000;

// int dr[]={0,0,1,-1};
int countt[1010101];
// int dc[]={1,-1,0,0};

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

	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	#endif
	
	int a,b,c;
	cin>>a>>b>>c;
	int cf=0;
	if(a==5)
		cf++;
	if(b==5)
		cf++;
	if(c==5)
		cf++;
	if(a==7)
	{
		if(cf==2)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		return 0;
	}
	else if(b==7)
	{
		if(cf==2)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		return 0;
	}
	else if(c==7)
	{
		if(cf==2)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
		return 0;
	}
	else
	{
		cout<<"NO"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){

int i,j,k;
int N;
int sum=0;
int count=0;

while(1){
i=0;
j=0;
k=0;
N=0;
sum=0;
count=0;
scanf("%d",&N);
if(N ==0){break;}
for(i=1;i<=N/2+1; i++){
  //printf("%d ",i);
  sum=i;
  for(j=1;j<=N;j++){
     sum+=(i+j);
     //printf("%d ",i+j);
     if(sum == N){
	//printf("N\n"); 
	count++;
	break;
     }
  }
//printf("\n");
sum=0;
}
printf("%d\n",count);
}
return 0;


}

Measured memory_bytes: 600
/* C/C++ program to remove invalid parenthesis */
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
int main() 
{ 
    ll n;
    cin>>n;
    ll W[n],V[n];
    ll weigh;
    cin>>weigh;
    for(ll i=0;i<n;i++)
    cin>>W[i]>>V[i];
    ll dp[n+1][weigh+1];
    
    for(ll i=0;i<=weigh;i++)
       dp[0][i]=0;
       
    for(ll i=0;i<=n;i++)
       dp[i][0]=0;
      
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=weigh;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j-W[i-1]>=0)
            {
                dp[i][j]=max(dp[i][j],dp[i-1][j-W[i-1]]+V[i-1]);
            }
        }
    }
    cout<<dp[n][weigh];

	return 0; 
} 


Measured memory_bytes: 79104
from math import inf
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)


def dfs(v,par):
    global cur
    vis[v]=1 ; disc[v]=cur ;low[v]=cur 
    cur+=1
    for i in g[v]:
        if vis[i]==0:
            dfs(i,v)
            low[v]=min(low[i],low[v])
            if low[i]>disc[v]:
                apts.add((min(v,i),max(v,i)))

        elif i!=par: low[v]=min(disc[i],low[v])
   
def articulation_pts():
    global apts,disc,low,vis
    disc=[0]*n ; low=[inf]*n ; vis=[0]*n ; apts=set()  
    for i in range(n):
        if vis[i]==0:
            dfs(i,-1)

n,e=map(int,input().split())
cur=0
g=[[] for i in range(n)]
for i in range(e):
    x,y=map(int,input().split())
    g[x].append(y)
    g[y].append(x)
articulation_pts()
apts=sorted(apts)
for i in apts:
    print(*i)




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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if((abs(a-c) <= d) || ((abs(a-b) <= d) && (abs(b-c)) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 998244353
#define mkp make_pair
typedef long long ll;
using namespace std;

class LazySegmentTree{
private:
  int n;
  vector<ll> node,lazy;

public:
  LazySegmentTree(vector<ll> v){
      n=1;
      while(n<v.size()) n*=2;
      node.resize(2*n-1,0);
      lazy.resize(2*n-1,0);
      
      for(int i=0;i<v.size();i++) node[i+n-1]=v[i];
      for(int i=n-2;i>=0;i--) node[i]=node[2*i+1]+node[2*i+2];
  }

  void eval(int k,int l,int r){
      if(lazy[k]!=0){
          node[k]+=lazy[k];
          if(r-l>1){
              lazy[2*k+1]+=lazy[k]/2;
              lazy[2*k+2]+=lazy[k]/2;
          }
          lazy[k]=0;
      }
  }

  void add(int a,int b,ll x,int k=0,int l=0,int r=-1){
      if(r<0) r=n;
      eval(k,l,r);
      if(b<=l||r<=a) return;
      if(a<=l&&r<=b){
          lazy[k]+=(r-l)*x;
          eval(k,l,r);
      }else{
          add(a,b,x,2*k+1,l,(r+l)/2);
          add(a,b,x,2*k+2,(r+l)/2,r);
          node[k]=node[2*k+1]+node[2*k+2];
      }
  }

  ll getSum(int a,int b,int k=0,int l=0,int r=-1){
      if(r<0) r=n;
      eval(k,l,r);
      if(b<=l||r<=a) return 0;
      if(a<=l&&r<=b) return node[k];

      ll vl,vr;
      vl=getSum(a,b,2*k+1,l,(l+r)/2);
      vr=getSum(a,b,2*k+2,(l+r)/2,r);
      return vl+vr;
  }
};

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

  vector<pair<ll,int>> v,w;
  for(int i=0;i<N;i++) w.push_back(mkp(y[i],i));
  for(int i=0;i<N;i++) v.push_back(mkp(x[i],i));
  map<ll,int> xmp,ymp;
  sort(v.begin(),v.end());
  sort(w.begin(),w.end());
  for(int i=0;i<N;i++){
    xmp[v[i].first]=i;
    ymp[w[i].first]=i;
  }

  LazySegmentTree lsg(vector<ll> (N+1,0));
  LazySegmentTree rsg(vector<ll> (N+1,0));

  vector<ll> ld(N+1,0),lu(N+1,0),rd(N+1,0),ru(N+1,0);
  for(int i=0;i<N;i++){
    int now=v[i].second;
    int val=ymp[y[now]];
    int z=lsg.getSum(0,val);
    int p=i-z;
    ld[i]=z;
    lu[i]=p;
    lsg.add(val,val+1,1);
  }
  for(int i=N-1;i>=0;i--){
    int now=v[i].second;
    int val=ymp[y[now]];
    int z=rsg.getSum(0,val);
    int p=N-1-i-z;
    rd[i]=z;
    ru[i]=p;
    rsg.add(val,val+1,1);
  }

  ll two[N+1]={};
  two[0]=1;
  for(int i=1;i<=N;i++) two[i]=two[i-1]*2%MOD;

  ll ans=0;
  for(int i=0;i<N;i++){
    ll resa=(two[ld[i]]-1)*(two[ru[i]]-1)%MOD;
    resa=resa*(two[N-(ld[i]+ru[i]+1)])%MOD;

    ll resb=(two[lu[i]]-1)*(two[rd[i]]-1)%MOD;
    resb=resb*(two[ru[i]]-1+two[ld[i]])%MOD;

    ll res=(resa+resb)%MOD;
    ans=(ans+res)%MOD;
    ans=(ans+two[N-1])%MOD;
  }

  cout<<(ans+MOD)%MOD<<endl;
  

  return 0;
}


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


int main() {
	size_t N;
	cin >> N;
	size_t l = 0;
	size_t l_max = 0;
	size_t h_prev = 0;
	for (size_t i = 0; i < N; ++i) {
		size_t h;
		cin >> h;

		if (h <= h_prev) {
			++l;
		}
		else {
			l_max = max(l_max, l);
			l = 0;
		}
		h_prev = h;
	}
	l_max = max(l_max, l);

	cout << l_max << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), k = in.ni();
        int[] p = in.ni(n);
        int ans = 0;
        Arrays.sort(p);
        for (int i = 0; i < k; i++) ans += p[i];
        out.println(ans);
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

int main(){
  int n, y;
  cin >> n >> y;
  
  int cnt_10000 = -1, cnt_5000 = -1, cnt_1000 = -1;
  int ans = 0;
  for(int i = 0; i <= n; i++){
    for(int j = 0; j + i <= n; j++){
      int k = n - i - j;
      int ans = 10000 * i + 5000 * j + 1000 * k;
      if(ans == y){
        cnt_10000 = i;
        cnt_5000 = j;
        cnt_1000 = k;
      }
    }
  }
  cout << cnt_10000 << " " << cnt_5000 << " " << cnt_1000 << endl;
  return 0;
}

Measured memory_bytes: 3636