akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <set>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

char s[5];

int main() {
    scanf("%s", s);
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
        printf("3\n");
    } else if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S') {
        printf("0\n");
    } else if(s[0] == 'R' && s[1] == 'R') {
        printf("2\n");
    } else if(s[1] == 'R' && s[2] == 'R') {
        printf("2\n");
    } else {
        printf("1\n");
    }


    return 0;
}


Measured memory_bytes: 3180
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  string s;
  cin >> s;
  ll v=0,ans=0;
  map<ll,ll> mp;
  ll n=s.size();
  mp[v]++;
  ll ket=1;
  reverse(s.begin(),s.end());
  for(int i=0;i<n;i++){
    v = v + (s[i]-'0')*ket;
    v %= 2019;
    ket = (ket*10)%2019;
    ans += mp[v];
    mp[v]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3748
import math
n,k = map(int, input().split())
a = list(map(int, input().split()))

g = a[0]
for i in range(n):
  g = math.gcd(g,a[i])

if k%g == 0 and k <= max(a):
  print ('POSSIBLE')
else:
  print ('IMPOSSIBLE')

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

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> A(m);
	for(int i = 0; i < m; i++){
		cin >> A[i];
	}
	int answer = n;
	for(int i = 0; i < m; i++){
		answer = answer - A[i];
	}
	if(answer >= 0){
		cout << answer;
	} else {
		cout << -1;
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main(){
  ll n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;

  ll f=min({a,b,c,d,e});

  cout << 4+(n+f-1)/f << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define cm(i) (Y+Z)*i + Z

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	int i = 0;
	while (cm(++i) <= X);
	say(i - 1);
}


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

ans = l[0]

minn = min(l)

if (minn == 0):
    print(0)
else:
    for i in range(1,len(l)):
        ans = ans * l[i]

        if ans >= 1000000000000000001:
            break
    
    if ans >= 1000000000000000001:
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 21656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// for (int i = 0; i < 105; i++)
		// cout.println(solve(i));

		long k = cin.nextLong();

		long millis = System.currentTimeMillis();

		String ans = solve(k);

		cout.println(ans);
		assert null != cout.format("elapsed %d", System.currentTimeMillis() - millis);
	}

	private static String solve(long k) {
		int n = 50;
		long[] a = LongStream.range(0, n).toArray();
		long x = k / n;
		for (int i = 0; i < n; i++)
			a[i] += n * x - k + x;
		long mod = k % n;
		for (int i = 0; i < mod; i++)
			a[i] += n + 1;
		String ans = Integer.toString(n) + System.lineSeparator()
				+ Arrays.stream(a).mapToObj(Long::toString).collect(Collectors.joining(" "));
		assert null != System.out.format("%s\r\n", ans);
		assert k == check(n, a);
		return ans;
	}

	private static long check(int n, long[] a) {
		// E: Judge ver. AC
		long ans = 0;
		long[] opes = new long[n];
		while (true) {
			boolean any = false;
			long sum = 0;
			for (int i = 0; i < n; i++) {
				opes[i] = a[i] / n;
				sum += opes[i];
				any |= opes[i] != 0;
				a[i] %= n;
			}
			for (int i = 0; i < n; i++)
				a[i] += sum - opes[i];

			ans += sum;
			if (!any)
				break;
		}
		assert null != System.out.format("check %d\r\n", ans);
		return ans;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 28500
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

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()
}

pub trait BinarySearch<T> {
    fn lower_bound(&self, &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                Ordering::Less => {
                    low = mid + 1;
                }
                Ordering::Equal | Ordering::Greater => {
                    high = mid;
                }
            }
        }
        low
    }
}

fn main() {
    let a = read::<String>()
        .chars()
        .map(|x| x.to_digit(36).unwrap() as usize - 10)
        .collect::<Vec<_>>();

    let n = a.len();

    let mut poses = vec![Vec::new(); 26];
    for (i, &ch) in a.iter().enumerate() {
        poses[ch].push(i);
    }

    let mut dp = vec![std::usize::MAX; n];
    let mut dp_from = vec![std::usize::MAX; n];
    let mut dp_from_ch = vec![std::usize::MAX; n];
    dp[n - 1] = 1;

    for i in (1..n).rev() {
        for ch in 0..26 {
            let pos_idx = poses[ch].lower_bound(&(i));
            if pos_idx == poses[ch].len() {
                if dp[i - 1] > 1 {
                    dp_from[i - 1] = std::usize::MAX;
                    dp_from_ch[i - 1] = ch;
                    dp[i - 1] = 1;
                }
            } else {
                let pos: usize = poses[ch][pos_idx];
                if dp[i - 1] > 1 + dp[pos] {
                    dp[i - 1] = 1 + dp[pos];
                    dp_from[i - 1] = pos;
                    dp_from_ch[i - 1] = ch;
                }
            }
        }
    }

    let mut min_dp = std::usize::MAX;
    let mut min_ch_begin = std::usize::MAX;
    for ch in 0..26 {
        if poses[ch].is_empty() {
            println!("{}", std::char::from_digit(ch as u32 + 10, 36).unwrap());
            return;
        }
        if min_dp > dp[poses[ch][0]] {
            min_dp = dp[poses[ch][0]];
            min_ch_begin = ch;
        }
    }

    let mut ans = vec![min_ch_begin];
    let mut itr = poses[min_ch_begin][0];
    loop {
        ans.push(dp_from_ch[itr]);
        itr = dp_from[itr];
        if itr == std::usize::MAX {
            break;
        }
    }
    println!(
        "{}",
        ans.iter()
            .map(|&x| std::char::from_digit(x as u32 + 10, 36).unwrap())
            .collect::<String>()
    );
}


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

int main(void){
  int x, y;
  cin >> x >> y;

  if(x == 2 && y == 2){
    cout << "Yes" << endl;
  } else if((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11)){
    cout << "Yes" << endl;
  } else if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)){
    cout << "Yes" << endl;
  } else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 764
N,D,A=map(int,input().split())
from heapq import heappop,heappush,heapify
B=[]
for _ in range(N):
    x,h=map(int,input().split())
    B.append((x,h))
heapify(B)

dic={}

ans=0
atk_cnt=0
while B:
    x,h=heappop(B)
    if h==-1:
        atk_cnt-=dic[x-1]
        continue
    if h<=A*atk_cnt:
        continue
    h-=A*atk_cnt
    sup=x+2*D
    bomb=(h-1)//A+1
    ans+=bomb
    dic[sup]=bomb
    atk_cnt+=bomb
    heappush(B,(sup+1,-1))
    
    
print(ans)


Measured memory_bytes: 52060
/* long long or int */
/* xx 396 */

#include<bits/stdc++.h>
using namespace std;

int A,B;

int main(){
	ios::sync_with_stdio(false);
	cin>>A>>B;
	if((A+B)%2==1){
		cout<<"IMPOSSIBLE"<<endl;
		return 0;
	}
	int K=(A+B)/2;
	if((A-K)>=0&&(B-K)<=0) cout<<K<<endl;
	else if((A-K)<=0&&(B-K)>=0) cout<<K<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000007
# define INF 2000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
int main() {
	int ans = 0, counter = 0, maxi = -1, mini = INF,pass=0;
	//new
	int a, b, c;
	int inp[23];
	cin >> inp[0]>>inp[1]>>inp[2];
	sort(inp, inp + 3);
	a = inp[0];
	b = inp[1];
	c = inp[2];
	if ((c - a) % 2 == 0 && (c - b) % 2 == 0) {
		cout << (c - a) / 2 + (c - b) / 2 << endl;
	}
	else if ((c - a) % 2 == 0 && (c - b) % 2 != 0) {
		cout << (c - a) / 2 + (c - b) / 2 + 2 << endl;
	}
	else if ((c - a) % 2 != 0 && (c - b) % 2 == 0) {
		cout << (c - a) / 2 + (c - b) / 2 + 2 << endl;
	}
	else if ((c - a) % 2 != 0 && (c - b) % 2 != 0) {
		cout << (c - a) / 2 + (c - b) / 2 + 1 << endl;
	}
}



Measured memory_bytes: 256
n , m , x = map(int,input().split())
c = []
a = []
for i in range(n):
    l = list(map(int,input().split()))
    c. append(l[0])
    a.append(l[1:m+1])
S = sum(c)
ans = S +1
for i in range(2**n):
    cost = 0
    sum = [0]*m
    for j in range(n):
        if ((i>>j)&1):
            cost += c[j]
            sum = [x + y for (x,y) in zip(sum,a[j])]  
            if all(i>=x for i in sum) == True:
                obj = sum
                ans = min(ans , cost)  
if ans > S:
    print(-1)
else:
    print(ans) 

Measured memory_bytes: 9232
/************************************************
* @Author: leaflove
* @Date:   2020-03-08 20:05:20
* @File:   hi.cpp
* @Remark:   
************************************************/
#include <bits/stdc++.h>
#define CSE(x,y) memset(x,y,sizeof(x))
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

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

const int maxn = 111;
char str[maxn];

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("in.in","r",stdin);
	// #endif
	cin>>str;
	int len=strlen(str);
	if(len&1){
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<len;i+=2){
		if(str[i]!='h'||str[i+1]!='i'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
result = [0 for _ in range(120)]
for i in a:
    x = format(i, "060b")[::-1]
    for j in range(60):
        result[j] = result[j]+(x[j]=="1")
result = [(n-i)*i for i in result]
for i in range(119):
    result[i+1] += result[i]//2
    result[i] = result[i]%2    
print(int("".join(map(str, result[::-1])), 2)%mod)

Measured memory_bytes: 125624
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    bitset<31> bs;
    for(int i=0; i<28; ++i){
        int a;
        cin >> a;
        bs[a] = true;
    }
    for(int i=1; i<=30; ++i){
        if(!bs[i])
            cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.lang.*;
class Main {
   public static void main(String[] args)
   {
      Scanner       scan = new Scanner(System.in);
      String        sca  = scan.next();
      StringBuilder str  = new StringBuilder(sca);
      String        sc   = scan.next();

      str.append(sc);
      Double n = Double.parseDouble(str.toString());
      int    N = (int)Math.sqrt(n);
      N = N * N;

      if(n != N){
         System.out.println("No");
         }
      else{
          System.out.println("Yes");
          }
   }
}


Measured memory_bytes: 21588
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String b = sc.next();
    switch (b) {
      case "A":
        System.out.println("T");
        break;
      case "T":
        System.out.println("A");
        break;
      case "G":
        System.out.println("C");
        break;
      case "C":
        System.out.println("G");
        break;
    }
  }
}

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

const int MAXN = 200005;

int a[MAXN], n;
int T[MAXN];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]), T[a[i]] = i;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		int c = 1;
		while (i <= n && T[i+1] > T[i]) c++, i++;
		cnt = max(cnt, c);
	}
	cout << n-cnt << endl;
	return 0;
}


Measured memory_bytes: 1792
# ABC 45, B - card game for three easy
A = list(input())
B = list(input())
C = list(input())

n = 'a'
count = 0
while count <= 300:
    if n == 'a':
        if A:
            n = A.pop(0)
        else:
            print('A')
            break
    if n == 'b':
        if B:
            n = B.pop(0)
        else:
            print('B')
            break
    if n == 'c':
        if C:
            n = C.pop(0)
        else:
            print('C')
            break
    count += 1


Measured memory_bytes: 3060
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = int(read())

x = S//100
y = S%100

yymm = (1<=y<=12)
mmyy = (1<=x<=12)

if yymm and mmyy:
    answer = 'AMBIGUOUS'
elif yymm and not(mmyy):
    answer = 'YYMM'
elif mmyy and not(yymm):
    answer = 'MMYY'
else:
    answer = 'NA'
print(answer)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const double pi=3.1415926535;
double a,b,x,p;
inline long long read(){
	long long x=0,f=1;
	char c;
	do{c=getchar();if(c=='-'){f*=-1;}}while(!isdigit(c));
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}
int main(){
	scanf("%lf%lf%lf",&a,&b,&x);
	x=x/a;
	if(2*x<a*b){
		p=((b*b)/(2*x));
		printf("%.10lf",atan(p)*180/pi);
	}
	else{
		x=a*b-x;
		p=((2*x)/(a*a));
		printf("%.10lf",atan(p)*180/pi);
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL -1

typedef struct node{
  int left;
  int right;
  int parent;}node;

int getSibling(int);
int getDegree(int);
int getDepth(int);
int getHeight(int);
void printTree(void);

node *tree;
int n;

int main(){
  int i,id,left,right;
  
  scanf("%d",&n);
  
  tree = (node *)malloc(sizeof(node)*n);
  for(i=0;i<n;i++){
    tree[i].parent = NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    tree[id].left = left;
    tree[id].right = right;
    tree[tree[id].left].parent = id;
    tree[tree[id].right].parent = id;
  }

  printTree();

  return 0;
}




int getSibling(int c){
  int left,right;
  if(tree[c].parent!=-1){
    left = tree[tree[c].parent].left;
    right = tree[tree[c].parent].right;

    if(left!=-1&&c!=left) return left;
    else if(right!=-1&&c!=right) return right;
  }
  return -1;
}

int getDegree(int c){
  int d=0;
  if(tree[c].left!=-1) d++;
  if(tree[c].right!=-1) d++;
 
  return d;
}

int getDepth(int c){
  int d=0;
  while(tree[c].parent!=-1){
    c=tree[c].parent;
    d++;
  }
  return d;
}

int getHeight(int c){
  int d=0;
  if(tree[c].left==-1&&tree[c].right==-1) return 0;
  if(tree[c].left==-1) return getHeight(tree[c].right)+1;
  if(tree[c].right==-1) return getHeight(tree[c].left)+1;
  if(getHeight(tree[c].left)<getHeight(tree[c].right))
    return getHeight(tree[c].right)+1;
  else return getHeight(tree[c].left)+1;
  return d;
}





void printTree(){
  int i,dep,h;
  for(i=0;i<n;i++){
    dep=getDepth(i);
    h=getHeight(i);
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,tree[i].parent,getSibling(i),getDegree(i),dep,h);
    if(dep==0) printf("root\n");
    else if(h==0) printf("leaf\n");
    else printf("internal node\n");
  }

  return;
}

Measured memory_bytes: 612
n, k = gets.strip.split.map { |v| v.to_i }
r, s, p = gets.strip.split.map { |v| v.to_i }
t = gets.strip.split('').map { |v| v.to_sym }

your_hands = []
hand_to_point = { :r => r, :p => p, :s => s }
points = 0

def hands_with_exception(index, hands)
  return hands[index] if 0 <= index && index < hands.size
  :out_of_bound
end

def hand_to_win(opp_hand, disable_hand, opp_next_hand)
  case opp_hand
  when :r
    return [:p, :win] if disable_hand != :p
    return [:s, :lose] if opp_next_hand == :s
    return [:r, :lose]
  when :p
    return [:s, :win] if disable_hand != :s
    return [:r, :lose] if opp_next_hand == :r
    return [:p, :lose]
  when :s
    return [:r, :win] if disable_hand != :r
    return [:p, :lose] if opp_next_hand == :p
    return [:s, :lose]
  end
end

(0..n-1).each do |i|
  hand = hand_to_win(hands_with_exception(i, t), hands_with_exception(i-k, your_hands), hands_with_exception(i+k, t))
  your_hands.push(hand[0])
  points += hand_to_point[hand[0]] if hand[1] == :win
end

puts points


Measured memory_bytes: 11132
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N, x = input_number_list()
    A = input_number_list()
    A.sort()
    ans = 0
    tmp_sum = 0
    for a in A:
        tmp_sum += a
        if tmp_sum > x:
            break
        else:
            ans += 1
    if ans == N and tmp_sum != x:
        ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n,a,b=map(int,input().split())

import math
import functools
 
def cmb(n,r):
    f = math.factorial
    return int(f(n) // f(r) // f(n-r))
 
v=list(map(int,input().split()))
v.sort(reverse=True)
print(sum(v[:a])/a)
x,y=v.count(v[a-1]), v[:a].count(v[a-1])
if v[0]==v[a-1]:
    ans=sum( cmb(x,i)    for i in range(a,min(b,x)+1))

else:
    ans=cmb(x,y)
print(ans)

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

int main() {
  string S;
  cin >> S;
  bool is_ac = true;
  int cnum = 0;
  for (int i=0; i<S.size(); i++) {
    if (i==0) {
      if (S.at(0)!='A') {
        is_ac = false; break;
      }
    } else if (i==1||i==S.size()-1) {
      if (S.at(i)<'a'||S.at(i)>'z') {
        is_ac = false; break;
      }
    } else {
      if (S.at(i) == 'C') cnum++;
      else {
        if (S.at(i)<'a'||S.at(i)>'z') {
          is_ac=false; break;
        }
      }
    }
  }
  if (is_ac&&cnum==1) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define f(x,y,z) for(int x = y ; x <= z ; x++)
#define fs(arr,n) for(int i = 1 ; i <= n ; i++) cin >> arr[i];
#define fsm(arr,n,m) for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) cin >> arr[i][j];
#define fp(arr,n) for(int i = 0 ; i < n ; i++) cout << arr[i] << " ";
#define fpm(arr,n,m) for(int i = 1 ; i <= n ; i++){ for(int j = 1 ; j <= m ; j++) {cout << arr[i][j] << " ";} cout << "\n";}
#define N 100005
using namespace std;
int n,m,sum[N],mini=999999999;
char arr[N];
int main() 
{
    scanf("%s",arr+1);
    int len = strlen(arr+1);
    for(int i = 1 ; i <= len ; i++)
    {
        sum[arr[i] - 'a']++;
    }
    for(int i = 0 ; i <= 26 ; i++)
    {
        if(sum[i] >= 1)
        {
            int maxi = 0,say = 0;
            for(int j = 1 ; j <= len ; j++)
            {
               
                if(arr[j] == i + 'a')
                { 
                    // cout << (char)(arr[j]) << " " << say << "\n";
                    maxi = max(maxi,say);
                    say = 0;
                    
                }
                else
                    say++;
            }
            maxi = max(maxi,say);
            mini = min(mini,maxi);
        }
    }
    cout << mini;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, q;
  cin >> n >> q;
  vector<ll> a;
  REP(i, n) {
    ll x;
    cin >> x;
    a.push_back(x);
  }

  vector<ll> sum(n + 1, 0), sumEven(n + 1, 0), sumOdd(n + 1, 0);
  REP(i, n) {
    sum[i + 1] = sum[i] + a[i];
    sumEven[i + 1] = sumEven[i] + ((i + 1) % 2 == 0 ? a[i] : 0);
    sumOdd[i + 1] = sumOdd[i] + ((i + 1) % 2 == 1 ? a[i] : 0);
  }

  vector<ll> query(q);
  REP(i, q) { cin >> query[i]; }

  REP(i, q) {
    ll x = query[i];
    ll ok = 0, ng = n + 1;
    while (ok + 1 < ng) {
      ll mid = (ok + ng) / 2;
      ll dl = abs(x - a[n - mid + 1 - 1]);
      ll dr = abs(x - a[n - (mid + 1) / 2 + 1 - 1]);
      (dl <= dr ? ok : ng) = mid;
    }
    ll ans;
    ans = sum[n] - sum[n - (ok + 1) / 2] +
          (n % 2 == 0 ? sumEven[n - ok] : sumOdd[n - ok]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 7192
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

B = [[0] * W for _ in range(H)]

X = []
for i, a in enumerate(A):
    X += [i + 1] * a

for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            B[i][j] = X[i * W + j]
        else:
            B[i][W - j - 1] = X[i * W + j]
for i in range(H):
    print(*B[i])

Measured memory_bytes: 9516
K, S = tuple(map(int, input().split()))

ret = 0 
for X in range(K+1):
  for Y in range(X, K+1):
    Z = S - X - Y
    if Z < Y: break
    if Z >= 0 and Z <= K:
      if X == Y and Y == Z: ret += 1
      elif X != Y and Y != Z and Z != X: ret += 6
      else: ret += 3

print (ret)

Measured memory_bytes: 3064
n=int(input())
a=list(map(int,input().split()))

ll=0
rr=0
llrr=0

result=0

for ll in range(n):

    while rr<n and a[rr]&llrr==0:
        llrr+=a[rr]
        rr+=1
    result+=rr-ll
    llrr=llrr^a[ll]

print(result)



    

Measured memory_bytes: 24712
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = Integer.parseInt(stdIn.next());
        String s = stdIn.next();

        int count = 0;
        int i = 0;
        while (i < n - 2) {
            if (s.charAt(i) == 'A') {
                if (s.charAt(i + 1) == 'B') {
                    if (s.charAt(i + 2) == 'C') {
                        count++;
                    }
                }
            }
            i++;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21972
import random

D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]

plus=0
minus=0
data=[[1 for i in range(D)] for j in range(26)]
ans=[0]*D
for i in range(D):
    t=random.randint(1,26)
    ans[i]=t
    plus+=s[i][t-1]
    if i!=0:
        for j in range(26):
            data[j][i]=data[j][i-1]+1
    data[t-1][i]=0
    minus+=sum(c[j]*data[j][i] for j in range(26))

eval=plus-minus
count=2000000
check=[]
while count:
    d=random.randint(2,D)
    q=random.randint(1,26)
    if ans[d-1]==q:
        continue
    if c[ans[d-1]-1]*data[ans[d-1]-1][d-2]>c[q-1]*data[q-1][d-2] or s[d-1][q-1]>s[d-1][ans[d-1]-1]:
        testplus=plus+s[d-1][q-1]-s[d-1][ans[d-1]-1]
        testminus=minus
        pre=ans[d-1]
        #print("pre",pre)

        day=0
        for j in range(d-1,D):
            if data[q-1][j]!=0:
                if j==d-1:
                    testminus+=day*c[q-1]-data[q-1][d-1]*c[q-1]
                else:
                    testminus+=(day+1-data[q-1][j])*c[q-1]
                    day+=1
            else:
                break

        day=0
        for j in range(d-1,D):
            if j==d-1:
                if j==0:
                    day=1
                    testminus+=c[pre-1]*day
                else:
                    day=1+data[pre-1][j-1]
                    testminus+=c[pre-1]*day
            elif data[pre-1][j]!=0:
                testminus+=(day+1-data[pre-1][j])*c[pre-1]
                day+=1
            else:
                break

        if testplus-testminus>eval:
            eval=testplus-testminus
            plus=testplus
            minus=testminus
            ans[d-1]=q
            for j in range(d-1,D):
                if data[q-1][j]!=0:
                    if j==d-1:
                        data[q-1][d-1]=0
                    else:
                        data[q-1][j]=data[q-1][j-1]+1
                else:
                    break

            for j in range(d-1,D):
                if j==d-1:
                    if j==0:
                        data[pre-1][j]=1
                    else:
                        data[pre-1][j]=1+data[pre-1][j-1]
                elif data[pre-1][j]!=0:
                    data[pre-1][j]=data[pre-1][j-1]+1
                else:
                    break
    else:
        continue

    count-=1
#print(eval)
for i in range(D):
    print(ans[i])


Measured memory_bytes: 89012
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
  val xs = IntArray(n)
  val s = readLine()!!
  var currentValue = 0
  var isNegative = false
  var currentIndex = 0
  for (c in s) {
    if (c == ' ') {
      xs[currentIndex] = currentValue * if (isNegative) -1 else 1
      currentValue = 0
      isNegative = false
      currentIndex++
    } else if (c == '-') {
      isNegative = true
    } else {
      currentValue *= 10
      currentValue += c - '0'
    }
  }
  xs[currentIndex] = currentValue * if (isNegative) -1 else 1
  return xs
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = fastReadInts(n)
  val xMax = xs.max()!!
  var dMax = -1
  var ansX = -1
  for (x in xs) {
    if (x == xMax) continue
    if (Math.min(x, xMax - x) > dMax) {
      dMax = Math.min(x, xMax - x)
      ansX = x
    }
  }
  println("$xMax $ansX")
}


Measured memory_bytes: 41536
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

void ini(int N, vi& par)
{
    par = vi(N);
    for (int n = 0; n < N; ++n) {
        par[n] = n;
    }
}
int root(int n, vi& par)
{
    if (par[n] == n) return n;
    return par[n] = root(par[n], par);
}
void unite(int n, int m, vi& par)
{
    if (root(n, par) == root(m, par)) return;
    par[par[root(n, par)]] = par[root(m, par)];
}
bool same(int n, int m, vi& par){
    return root(n, par) == root(m, par);
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, K, L;
    cin >> N >> K >> L;
    vi rpar, tpar;
    ini(N, rpar); ini(N, tpar);
    for (int k = 0; k < K; ++k) {
        int p, q;
        cin >> p >> q;
        --p; --q;
        unite(p, q, rpar);
    }
    for (int l = 0; l < L; ++l) {
        int r, s;
        cin >> r >> s;
        --r; --s;
        unite(r, s, tpar);
    }
    vector<pii> vp;
    for (int n = 0; n < N; ++n) {
        vp.push_back({root(n, rpar), root(n, tpar)});
    }
    sort(vp.begin(), vp.end());
    for (int n = 0; n < N; ++n) {
        pii tmp = {root(n, rpar), root(n, tpar)};
        cout << upper_bound(vp.begin(), vp.end(), tmp) - lower_bound(vp.begin(), vp.end(), tmp) << "\n";
    }

    return 0;
}


Measured memory_bytes: 3956
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int [] values = new int[5];
        for (int i = 0; i < 5; i++) {
            values[i] = Integer.parseInt(input.readLine());
        }
        int k = Integer.parseInt(input.readLine());

        for (int i = 0; i < 5; i++) {
            for (int j = i+1; j < 5; j++) {
                if (Math.abs(values[i] - values[j]) > k){
                    System.out.println(":(");
                    return;
                }
            }
        }
        System.out.println("Yay!");
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <functional>

struct Closed_Section {
    bool valid;
    int64_t begin;
    int64_t end;
    Closed_Section(bool _valid, int64_t _begin, int64_t _end) {
        valid = _valid; begin = _begin; end = _end;
    }
    Closed_Section() {
        valid = false, begin = 0; end = -1; //配列を定義するためにデフォルトコンストラクタが必要。
    }
    int64_t size() { return valid ? end - begin + 1 : 0; }
    void dump() { std::cout << "valid:" << valid << " begin:" << begin << " end:" << end << std::endl; }
};

Closed_Section binary_search(const int64_t L, const int64_t R, std::function<bool(int64_t)> func) {
    if (R < L) { return Closed_Section(false, L, R); }
    const bool res_L = func(L);
    const bool res_R = func(R);
    if (res_L && res_R) {
        return Closed_Section(true, L, R);
    } else if (!res_L && !res_R) {
        return Closed_Section(false, 0, -1);
    } else {
        int64_t lb = L;
        int64_t ub = R;
        while (lb + 1 < ub) {
            int64_t mid = (lb + ub) / 2;
            if (res_L == func(mid)) {
                lb = mid;
            } else {
                ub = mid;
            }
        }
        return res_L ? Closed_Section(true, L, lb) : Closed_Section(true, ub, R);
    }
}

Closed_Section binary_search(const Closed_Section& cs, std::function<bool(int64_t)> func) {
    return cs.valid ? binary_search(cs.begin, cs.end, func) : cs;
}

// end of template

int64_t N, Q;
std::string s;
const int64_t MAX_Q = 2e5 + 10;
char t[MAX_Q], d[MAX_Q];

int64_t calc(int64_t pos) {
    for (int64_t i = 1; i <= Q; i++) {
        if (t[i] == s[pos]) {
            if (d[i] == 'L') {
                pos--;
            } else {
                pos++;
            }
            if (pos == 0 || pos == N+1) {
                return pos;
            }
        }
    }
    return pos;
}

int main(int argc, char **argv) {
    std::cin >> N >> Q;
    std::cin >> s;
    s = "!" + s;
    for (int64_t i = 1; i <= Q; i++) {
        std::cin >> t[i] >> d[i];
    }
    auto cs = binary_search(1, N, [&](int64_t i){
        return 1 <= calc(i);
    });
    cs = binary_search(cs, [&](int64_t i){
        return calc(i) <= N;
    });
    std::cout << cs.size() << std::endl;
}

Measured memory_bytes: 984
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 105

using namespace std;

int T[SIZE];
bool A[SIZE],B[SIZE];
int rt[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	int mn=n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&T[i]);
		mn=min(mn,T[i]);
	}
	vector <int> vec;
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(T[i]!=mn) vec.push_back(T[i]);
		else
		{
			if(cnt>0) vec.push_back(T[i]);
			cnt++;
		}
	}
	int mx=0;
	for(int j=0;j<vec.size();j++) mx=max(mx,vec[j]);
	int nxt=mx-mn;
	if(nxt!=mn&&nxt!=mn-1)
	{
		puts("Impossible");
		return 0;
	}
	//重心に行ってから、mn or nxt の距離の方へ行く
	//うまく分けて1からの連続区間になればいい
	for(int i=0;i<vec.size();i++) rt[vec[i]]++;
	if(rt[mn]>=2)
	{
		puts("Impossible");
		return 0;
	}
	for(int i=mn+1;i<=mx;i++) rt[i]--;
	for(int i=nxt+1;i<=mx;i++) rt[i]--;
	for(int i=0;i<=mx;i++)
	{
		if(rt[i]<0||(i<=nxt&&rt[i]>0))
		{
			puts("Impossible");
			return 0;
		}
	}
	puts("Possible");
	return 0;
}
/*
mn+1,mn+2,...,mn+nxt
nxt+1,nxt+2,...,nxt+mn
があればいい & しかない
*/


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

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    ll N,X,aa,bb; cin >> N;
    if(N%2==1)
    cout << ((N-1)/2)*((N+1)/2) << endl;
    else{
        cout << ((N+1)/2)*N/2 << endl;
    }
  }


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void) {
  int n;
  cin>>n;
  ll t = 1;
  ll a = 1;
  for(int i=0; i<n; i++) {
    ll x, y;
    cin>>x>>y;
    if(x >= t and y >= a) {
      t = x;
      a = y;
    } else {
      ll q0 = t / x;
      ll r0 = t % x;
      ll t0, a0;
      if(r0 == 0) {
	a0 = y * q0;
	t0 = x * q0;
      } else {
	a0 = y * (q0 + 1);
	t0 = x * (q0 + 1);
      }
      if(a0 < a) {
	ll q = a / a0;
	ll r = a % a0;
	if(r == 0) {
	  a0 = a0 * q;
	  t0 = t0 * q;
	} else {
	  a0 = a0 * (q + 1);
	  t0 = t0 * (q + 1);
	}
      }
      ll q1 = a / y;
      ll r1 = a % y;
      ll t1, a1;
      if (r1==0) {
	a1 = y * q1;
	t1 = x * q1;
      } else {
	a1 = y * (q1+1);
	t1 = x * (q1+1);
      }
      if(t1 < t) {
	ll q = t / t1;
	ll r = t % t1;
	if(r == 0) {
	  a1 = a1 * q;
	  t1 = t1 * q;
	} else {
	  a1 = a1 * (q + 1);
	  t1 = t1 * (q + 1);
	}
      }
      if(t0 + a0 < t1 + a1) {
	t = t0;
	a = a0;
      } else {
	t = t1;
	a = a1;
      }
    }
  }
  std::cout << t+a << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n,m,i,j,r,tmp;
  scanf("%d %d",&n,&m);
  int a[100][100]={{0}};
  int b[100]={0};
  int c[100][100]={{0}};
  
  for(i=0;i < n;i++){
      for(j=0;j < m;j++){
          scanf("%d",&a[i][j]);
      }
  }
  for(r=0;r < m;r++){
      scanf("%d",&b[r]);
  }
  
  for(i=0;i<n;i++){
      for(j=0;j<m;j++){
          tmp = a[i][j] * b[j];
          a[i][j] = tmp;
          if(j==0){
              c[i][j] = a[i][j];
          }else{
              c[i][j] = c[i][j-1]+a[i][j];
          }
        }
    }
  
  for(i=0;i<n;i++){
      printf("%d\n",c[i][m-1]);
  }


    
   return 0;
}


Measured memory_bytes: 2144
fn main() {
    proconio::input! {
        n: usize,
        a_s: [usize; n],
    }
    #[derive(Clone, Copy)]
    enum State {
        Unknown,
        EqualOrMore,
        EqualOrLess,
    }
    use State::*;
    let mut state = Unknown;
    let mut count = 1usize;
    for w in a_s.windows(2) {
        match (state, w[0].cmp(&w[1])) {
            (Unknown, std::cmp::Ordering::Equal) => {}
            (Unknown, std::cmp::Ordering::Greater) => {
                state = EqualOrMore;
            }
            (Unknown, std::cmp::Ordering::Less) => {
                state = EqualOrLess;
            }
            (EqualOrMore, std::cmp::Ordering::Equal) => {}
            (EqualOrMore, std::cmp::Ordering::Greater) => {}
            (EqualOrMore, std::cmp::Ordering::Less) => {
                count += 1;
                state = Unknown;
            }
            (EqualOrLess, std::cmp::Ordering::Equal) => {}
            (EqualOrLess, std::cmp::Ordering::Greater) => {
                count += 1;
                state = Unknown;
            }
            (EqualOrLess, std::cmp::Ordering::Less) => {}
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 3672
#include <stdio.h>
int main(){
  int i,j,a,b,hai1[100000],hai2[50000],c1=0,c2=0,left,right,mid;
  scanf("%d",&a);
  for(i=0;i < a ; i++){
    scanf("%d",&hai1[i]);
  }
  scanf("%d",&b);
  for(i=0;i < b ; i++){
    scanf("%d",&hai2[i]);
  }
 
 
  for(i=0;i < b ; i++){
    left=0;
    right=a;
    while(left <= right){
      mid=(right+left)/2;
      if(hai1[mid]==hai2[i]){
        c1++;
        c2++;
        break;
        if(c2 >=2){
          c1--;
        }
      }
      if(hai1[mid] < hai2[i]){
        left=mid+1;
      }
      else if(hai1[mid] > hai2[i]){
        right=mid-1;
      }
    
    }
   
  }
  printf("%d\n",c1);
  return 0;
}




Measured memory_bytes: 2352
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
    const int MOD=1e9+7;
    ll mod(ll x){
        return (x%MOD + MOD)%MOD;
    }
    ll mul(ll a , ll b){
        return mod(mod(a)*mod(b));
    }
 
    void solve(){
        int n,k;
        cin>>n>>k;
        vector<ll>pos;
        vector<ll>neg;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            if(x>0)
                pos.push_back(x);
            else
                neg.push_back(x);
        }
        ll ans=1;
        if((int)pos.size()){
            if(k%2){
                sort(pos.begin(),pos.end());
                ans=mul(ans,pos.back());
                pos.pop_back();
                --k;
            }
            vector<ll>ok;
            sort(pos.begin(),pos.end(),greater<>());
            sort(neg.begin(),neg.end());
            for(int i=0;i+1<(int)pos.size();i+=2)
                ok.push_back(pos[i]*pos[i+1]);
            for(int i=0;i+1<(int)neg.size();i+=2)
                ok.push_back(neg[i]*neg[i+1]);
            if((int)pos.size()%2 && (int)neg.size()%2)
                ok.push_back(pos.back()*neg.back());
            sort(ok.begin(),ok.end(),greater<>());
            for(int i=0;i<(k/2);i++)
                ans=mul(ans,ok[i]);
            cout<<ans;
        }
        else{
            sort(neg.begin(),neg.end());
            if(k%2)
                reverse(neg.begin(),neg.end());
            for(int i=0;i<k;i++)
                ans=mul(ans,neg[i]);
            cout<<ans;
        }
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
            solve();
        }
        return 0;
    }

Measured memory_bytes: 6488
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;	
};

Node *nil;

Node* listSearch(int key) {
	Node *cur = nil->next;
	while (cur != nil && cur->key != key) {
		cur = cur->next;
	}
    return cur;
}

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	Node *cur = nil->next;
	int isf = 0;
	while(1) {
		if (cur == nil) break;
		if (isf++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t) {
	if(t==nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	deleteNode(nil->next);
}

void deleteLast() {
	deleteNode(nil->prev);
}

void deleteKey(int key) {
	deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
    x->prev = nil;	
}

int main() {
	int key, n, i;
	int size = 0;
	char com[20];
    int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for(i=0; i<n; i++) {
		scanf("%s%d", com, &key);
		if(com[0] == 'i') {
			insert(key);
			np++;
			size++;
		} else if(com[0] == 'd'){
			if(strlen(com) > 6) {
				if(com[6] == 'F') deleteFirst();
				else if (com[6] == 'L') deleteLast(); 
			} else {
				deleteKey(key);
			}
			nd++;
			size++;
		}
	}
	
	printList();
    
	return 0;	
	
}

Measured memory_bytes: 33832
#include <cmath>
#include <cstdio>
#include <cstring>

const int mod = 1e9 + 7;
const int MAXN = 1e5 + 5, MAXS = 4e4;

template<typename _T>
void read( _T &x )
{
	x = 0;char s = getchar();int f = 1;
	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}
	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}
	x *= f;
}

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

int inv( const int );
int qkpow( int, int );
void add( int &x, const int v );

struct matrix
{
	int mat[4][4];
	int n, m;
	
	matrix() { n = m = 0, clr(); }
	matrix( const int N ) { n = m = N, clr(); }
	matrix( const int N, const int M ) { n = N, m = M, clr(); }
	void clr() { memset( mat, 0, sizeof mat ); }
	
	int* operator [] ( const int indx ) { return mat[indx]; }
	
	matrix operator * ( matrix b ) const 
	{
		matrix ret( n, b.m );
		for( int i = 1 ; i <= n ; i ++ )
			for( int k = 1 ; k <= m ; k ++ )
				if( mat[i][k] )
					for( int j = 1 ; j <= b.m ; j ++ )
						add( ret[i][j], 1ll * mat[i][k] * b[k][j] % mod );
		return ret;
	}
	
	void operator *= ( matrix b ) { *this = *this * b; }
};

matrix A[MAXS], Art[MAXS], B;

int N, M, rt;

int inv( const int a ) { return qkpow( a, mod - 2 ); }
matrix qkpow( const int n ) { return Art[n / rt] * A[n % rt]; }
void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }

matrix I( const int n )
{
	matrix ret( n );
	for( int i = 1 ; i <= n ; i ++ )
		ret[i][i] = 1;
	return ret;
}

void init()
{
	Art[0] = A[0] = I( 3 );
	A[1] = B = matrix( 3, 3 );
	A[1][1][1] = 1, A[1][1][2] = 2, A[1][1][3] = 1;
	A[1][2][2] = 1, A[1][2][3] = 1;
	A[1][3][1] = 1, A[1][3][2] = 2, A[1][3][3] = 2;
	B[1][1] = 1, B[1][2] = 2, B[1][3] = 1;
	B[2][2] = 1, B[2][3] = 1;
	B[3][3] = 1;
	
	rt = ceil( sqrt( N ) );
	for( int i = 2 ; i < rt ; i ++ ) A[i] = A[i - 1] * A[1];
	Art[1] = A[rt - 1] * A[1];
	for( int i = 2 ; i < rt ; i ++ ) Art[i] = Art[i - 1] * Art[1];
}

int qkpow( int base, int indx )
{
	int ret = 1;
	while( indx )
	{
		if( indx & 1 ) ret = 1ll * ret * base % mod;
		base = 1ll * base * base % mod, indx >>= 1;
	}
	return ret;
}

int main()
{
	read( N ), read( M ), init();
	
	matrix beg( 1, 3 );
	beg[1][1] = 1;
	
	int lst = 0;
	for( int i = 1, p ; i <= M ; i ++ )
	{
		read( p );
		beg *= qkpow( p - lst );
		beg *= B, lst = p + 1;
	}
	beg *= qkpow( N - lst );
	write( beg[1][3] ), putchar( '\n' );
	return 0;
}

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

int n, k;

int main() {
	cin >> n;
	for(int x = 0 ; x <= 100 ; ++ x) {
		for(int y = 0 ; y <= 100 ; ++ y) {
			if(4 * x + 7 * y == n) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
}

// 4x+7y=n

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

int main(){
  int x,i=0,n[10000];
  while(1){
    cin>>x;
    if(x==0) break;
    n[i]=x;
    i++;
  }
  for(int j=0;j<i;j++){
  cout<<"Case "<<j+1<<": "<<n[j]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3052
let () = Scanf.scanf "%s\n%s" @@ fun a b ->
  if String.length a < String.length b then print_endline "LESS"
  else if String.length a > String.length b then print_endline "GREATER"
  else
    try
      Array.init (String.length a) (fun i -> Char.code b.[i] - Char.code a.[i])
      |> Array.to_list
      |> List.find (( <> ) 0)
      |> (fun d -> if 0 < d then "LESS" else "GREATER")
      |> print_endline
    with Not_found -> print_endline "EQUAL"


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using pii = pair<int,int>;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }

int N,M;
vector<vector<int> > A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
    A.assign(N,vector<int>(M,0));
    for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++)
            cin >> A[i][j];
}

void solve(){
    set<int> used;
    int ans=N+1;
    while(used.size()<M){
        unordered_map<int,int> cnt;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < M; j++)
            {
                if(used.find(A[i][j])!=used.end()) continue;
                cnt[A[i][j]]++;
                break;
            }
        }
        auto itr = max_element(cnt.cbegin(),cnt.cend(),[](pii a, pii b){return a.second < b.second;});
        ans = min(ans, itr->second);
        used.insert(itr->first);
    }
    cout << ans << endl;
}

int main()
{
    input();    
    solve();
    return 0;
}


Measured memory_bytes: 640