akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, K): (usize, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let a: Vec<i64> = (0..N)
        .map(|_| {
                let mut line: String = String::new();
                std::io::stdin().read_line(&mut line).unwrap();
                line.trim().parse().unwrap()
        })
        .collect();

    struct SegmentTree<T: Clone + Copy, F: Fn(T, T) -> T>{
        n: usize,
        f: F,
        e: T,
        x: Vec<T>
    }

    impl<T: Clone + Copy, F: Fn(T, T) -> T> SegmentTree<T, F> {
        fn new(n: usize, f: F, e: T) -> SegmentTree<T, F> {
            let m = 1 << format!("{:b}", n).len();
            SegmentTree { n: m, f: f, e: e, x: vec![e; 2 * m - 1] }
        }
        fn update(&mut self, i: usize, y: T) {
            let mut j = i + self.n - 1;
            self.x[j] = y;
            while j > 0 {
                j = (j - 1) / 2;
                self.x[j] = (self.f)(self.x[2 * j + 1], self.x[2 * j + 2]);
            }
        }
        fn find(&self, s: usize, t: usize) -> T { self.q(0, 0, self.n, s, t) }
        fn q(&self, i: usize, l: usize, r: usize, s: usize, t: usize) -> T {
            if l >= t || r <= s { self.e }
            else if s <= l && r <= t { self.x[i] }
            else {
                (self.f)(
                    self.q(2 * i + 1, l, (l + r) / 2, s, t),
                    self.q(2 * i + 2, (l + r) / 2, r, s, t)
                )
            }
        }
    }

    let acc = a.iter().scan(0, |state, &x| { *state += x - K; Some(*state) }).collect::<Vec<_>>();
    let sorted_acc = {
        let mut sorted_acc = acc.clone();
        sorted_acc.push(0);
        sorted_acc.sort();
        sorted_acc
    };
    let mut p = std::collections::HashMap::new();
    let mut r = 0;
    p.insert(sorted_acc[0], 0);
    for i in 0..N {
        if sorted_acc[i + 1] > sorted_acc[i] {
            r += 1;
        }
        p.insert(sorted_acc[i + 1], r);
    }
    let mut c = SegmentTree::new(N, |x, y| x + y, 0);
    let mut res: usize = 0;
    c.update(p[&0], 1);
    for i in 0..N {
        res += c.find(0, p[&acc[i]] + 1);
        let x = c.find(p[&acc[i]], p[&acc[i]] + 1) + 1;
        c.update(p[&acc[i]], x);
    }

    let ans = res;
    println!("{}", ans);
}

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

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	char area[100][100];
	for(int i = 0; i < 100; i++){
		for(int j = 0; j < 100; j++){
			if(i < 50) area[i][j] = '.';
			else area[i][j] = '#';
		}
	}

	int ain = 1, bin = 1;
	int w, h;
	w = 0, h = 0;
	while(true){
		if(bin == b) break;
		area[w][h] = '#';
		bin++;
		h += 2;
		if(h == 100){
			w += 2;
			h = 0;
		}
	}
	w = 51, h = 0;
	while(true){
		if(ain == a) break;
		area[w][h] = '.';
		ain++;
		h += 2;
		if(h == 100){
			w += 2;
			h = 0;
		}
	}

	cout << 100 << " " << 100 << endl;
	for(int i = 0; i < 100; i++){
		for(int j = 0; j < 100; j++){
			cout << area[i][j];
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int[] p = new int[n];
		for (int i=0; i<n; i++) {
			p[i] = sc.nextInt();
		}

		int max = p[0];
		int index = 0;
		for (int i = 0; i < n; i++) {
			if (p[i] > max) {
				max = p[i];
				index = i;
			}
		}

		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (i == index) {
				sum += p[i]/2;
				continue;
			}

			sum += p[i];
		}

		System.out.println(sum);
	}

}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int n = cin.NextInt();
        int k = cin.NextInt();
        string s = cin.Next();
        int index = k - 1;

        char[] tmp = s.ToCharArray();
        tmp[index] = Char.ToLower(s[index]);
        Console.WriteLine(tmp);
        
        

    }

}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int abc = 111; abc <= 999; abc += 111)
    if (abc >= N && ans == 0) ans = abc;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long int ll;

int dp[405][405][45];

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

  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector < int > a(n + 1), b(n + 1), c(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i] >> c[i];

  for (int i = 0; i < 405; i++) {
    for (int j = 0; j < 405; j++) {
      for (int k = 0; k < 45; k++) dp[i][j][k] = 1e9 + 5;
    }
  }

  for (int k = 0; k < 45; k++) dp[0][0][k] = 0;

  for (int i = 0; i < 405; i++) {
    for (int j = 0; j < 405; j++) {
      for (int k = 1; k <= n; k++) {
        if (i - a[k] >= 0 && j - b[k] >= 0) dp[i][j][k] = min(dp[i - a[k]][j - b[k]][k - 1] + c[k], dp[i][j][k - 1]);
        else dp[i][j][k] = dp[i][j][k - 1];
      }
    }
  }

  int min_cst = INT_MAX;
  for(int i = ma; i < 405; i += ma) {
    int j = (i * mb) / ma;
    if (j >= 405) continue;
    min_cst = min (min_cst, dp[i][j][n]);
  }

  if(min_cst == 1e9 + 5) cout << -1 << '\n';
  else cout << min_cst << '\n';
}


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

int main(){
    string b;
    cin >> b;
    if(b == "A"){
        cout << "T" << endl;
    }
    else if(b == "T"){
        cout << "A" << endl;
    }
    else if(b == "C"){
        cout << "G" << endl;
    }
    else{
        cout << "C" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <cmath>
using namespace std;
using ll = long long;

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

    string S, T;
    cin >> S >> T;

    int i;
    for (i = 0; i < S.length(); i++) {
        if (S == T) {
            cout << "Yes" << endl;
            break;
        }
        S = S.back() + S.substr(0, S.length()-1);
    }

    if (i == S.length())
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
  	sort(A, A+N);
    string ans = "YES";
    for (int i = 1; i < N; i++)
    {
        if(A[i-1]==A[i]) ans = "NO";
    }
    cout << ans << endl;
}

Measured memory_bytes: 4372
// vim: foldmethod=marker
#include <iostream> // cout, endl, cin{{{
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
typedef long long ll;/*}}}*/

int main(int argc, char *argv[])
{
  ll a, b, k;
  cin >> a >> b >> k;

  // while (k > 0) {
  //   if (a > 0) {
  //     a--;
  //   } else if (b > 0) {
  //     b--;
  //   }
  //   k--;
  // }

  if (a > k) {
    a = a - k;
  } else {
    k = k - a;
    a = 0;
    if (b > k) {
      b = b - k;
    } else {
      b = 0;
    }
  }

  cout << a << " " << b << endl;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;

int a[3];
int holding;
bool sorted;

int main() {
    
	cin >> a[0] >> a[1] >> a[2];

	while (sorted != true) {

		sorted = true;

		for (int i = 0; i < 2; i++) {

			if (a[i] < a[i + 1]) {

				holding = a[i + 1];
				a[i + 1] = a[i];
				a[i] = holding;

				sorted = false;
			}
		}
	}

	cout << (a[0] * 10) + a[1] + a[2];

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<climits>
#include<cstring>
#define int long long
using namespace std;

int N,a[100005];
int dp[100005];

int function(int init){
  if(init==(N-1))
    return 0;
  if(init>=N)
    return INT_MAX;
  if(dp[init]!=-1)
    return dp[init];

  int left = abs(a[init]-a[init+1])+ function(init+1);
  int right = INT_MAX;

  if(init+2<N)
  {
    right = abs(a[init]-a[init+2])+function(init+2);
  }
  return dp[init] = min(left,right);
}
signed main()
{
  cin>>N;
  memset(dp,-1,sizeof dp);
  for(int i=0;i<N;i++)
    cin>>a[i];
  cout<<function(0);
}

Measured memory_bytes: 4992
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
         
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        int ans = b;
        
        if(a<=12 && a>=6){
        	ans /= 2;
        }
        
        if(a<=5){
        	ans = 0;
        }
        
        System.out.println(ans);
        
    }
	
}


class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define int long long

using namespace std;


signed main(){
  int N;
  string S;
  int K;
  char okikae;


  cin>>N;
  cin>>S;
  cin>>K;
  okikae = S[K-1];
  rep(i, N){
    if(S[i]==okikae){
      cout << okikae;
    }else{
      cout << '*';
    }
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define input freopen("input.txt", "r", stdin);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>=30) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3612
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;


void solve(long long H, long long A){
    long long a = H/A;
    if(H%A==0)cout<<a<<endl;
    else cout<<a+1<<endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long A;
    scanf("%lld",&A);
    solve(H, A);
    return 0;
}


Measured memory_bytes: 384
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define ll long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vii vector<ppi>
#define vll vector<ll>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}


int main()
{      
  fastio();
  ll n,m,i,j,t;
  cin>>n;
  map<ll,ll> hash;
  int a[n];
  for(i=0;i<n;i++)
  {
  	cin>>a[i];
  	hash[a[i]]++;
  }
  ll total_ways=0;
  for(auto it:hash)
  {
  	if(it.se>=2){
  		ll p=it.se;
  		if(p>2)
  			total_ways+=(p*(p-1))/2;
  		else
  			total_ways+=1;
  	}
  }
  for(i=0;i<n;i++)
  {
  	int present=hash[a[i]];
  	present--;
  	if(present>=1)
  		cout<<total_ways-present<<"\n";
  	else
  		cout<<total_ways<<"\n";
  }
  return 0;
}

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

l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append([a,b])

l=sorted(l,key=lambda x:x[0])
ans=0
for i in l:
    if m>i[1]:
        ans+=(i[0]*i[1])
        m-=i[1]
    else:
        ans+=(i[0]*m)
        break
print(ans)    

Measured memory_bytes: 21976
#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 n, k;
  cin >> n >> k;

  vector<priority_queue<int>> a(n);
  rep(i, n) {
    int t, d;
    cin >> t >> d;
    t--;
    a[t].push(d);
  }

  vector<pair<int, bool>> b;
  rep(i, n) {
    if (a[i].empty()) continue;

    bool first = true;
    while (!a[i].empty()) {
      if (first) {
        b.push_back(make_pair(a[i].top(), first));
        first = false;
      } else {
        b.push_back(make_pair(a[i].top(), first));
      }
      a[i].pop();
    }
  }

  sort(b.rbegin(), b.rend());

  ll ans = 0;
  int c = 0;
  ll d = 0;
  int e = 0;
  rep(i, k) {
    d += b[i].first;
    c += b[i].second ? 1 : 0;
    e = i;
  }
  ans += d;
  ans += (ll)c * c;

  for (int i = k; i < n; i++) {
    if (c == k) break;
    if (!b[i].second) continue;
    c++;
    while (b[e].second) {
      e--;
    }
    d -= b[e].first;
    e--;
    d += b[i].first;
    ans = max(ans, d + (ll)c * c);
  }

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

Measured memory_bytes: 7672
import sys
import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]

a, b, c = readIntN()
minv = min(a, b)
maxv = max(a, b)
ret = 'Yes' if minv < c < maxv else 'No'
print(ret)

Measured memory_bytes: 21564
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main {
  val DIRS = Array("R","D","L","U")
  val tox = Array(1,0,-1,0)
  val toy = Array(0,1,0,-1)

  def f(x:Int,y:Int,d:Int,v:Array[String],h:Array[String]):(Int,Int,Int,String) = {
    val path = d match {
          case 3 => v(y-1)(x)
          case 0 => h(y)(x)
          case 1 => v(y)(x)
          case 2 => h(y)(x-1)
          case _ => '0'
    }
    if(path == '1') (tox(d),toy(d),d,DIRS(d)) else f(x,y,(d+1)%4,v,h)
  }


  def getPath(x:Int,y:Int,d:Int,s:String,v:Array[String],h:Array[String]):String = {
    if(x==1 && y==1) s
    else {
      val (x2,y2,d2,s2) = f(x,y,(d+3)%4,v,h)
      getPath(x+x2,y+y2,d2,s+s2,v,h)
    }
  }

  def main(args:Array[String]) = {
    val v = new ArrayBuffer[String]
    val h = new ArrayBuffer[String]

    h += "0"*6; v += "0"*7
    for(i<-1 to 4) { h += "0"+readLine.trim+"0"; v += "0"+readLine.trim+"0" }
    h += "0"+readLine.trim+"0"
    v += "0"*7; h += "0"*6

    println(getPath(2,1,0,"R",v.toArray,h.toArray))
  }
}

Measured memory_bytes: 43640
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    set<string> s;
    IN(n);
    rep(i, n)
    {
        string t;
        cin >> t;
        s.emplace(t);
    }
    cout << s.size() << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

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

int main()
{
    int k, s;
    int x, y, z;
    int ans = 0;

    cin >> k >> s;

    for (int x = 0; x <= k; ++x){
        for (int y = 0; y <= k; ++y){
            z = s - x - y;
            if (0 <= z && z <= k){
                ans = ans + 1;
             }
         }
     }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int ans,n,m;
char a[100][100];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
vector<vector<int>>dist;
void bfs(int r,int c)
{
    queue<pair<int,int>>q;
    dist=vector<vector<int>>(n,vector<int>(m,1e5));
    q.push({r,c});
    dist[r][c]=0;
    while(!q.empty()){
        pair<int,int>p=q.front();
        int r=p.first,c=p.second;
        q.pop();
        for(int i=0;i<4;i++){
            if(r+dx[i]<n && c+dy[i]<m && min(r+dx[i],c+dy[i])>=0 && a[r+dx[i]][c+dy[i]]=='.'){
                if(dist[r+dx[i]][c+dy[i]]==1e5){
                    dist[r+dx[i]][c+dy[i]]=dist[r][c]+1;
                    ans=max(ans,dist[r+dx[i]][c+dy[i]]);
                    q.push({r+dx[i],c+dy[i]});
                }
            }
        }
    }
}
main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j]=='.'){
                bfs(i,j);
            }
        }
    }
    cout<<ans<<"\n";
}   

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

int main() {
    int n; cin>>n;
    while(n != 0){
        int ans = 0;
        for(int i=0;i*i*i<151200; i++){
            int s = 0;
            for(int j=0; s <= n ;j++){
                ans = max(ans, s);
                s = pow(i, 3) + (j*(j+1)*(j+2))/6.0;
            }
        }
        cout << ans << endl;
        cin >> n;
    }
}



Measured memory_bytes: 3172
#include <stdio.h>

int main(void)
{
	int n, i, j, k, N[11][11] = {0};
	
	while (scanf("%d", &n) != 0)
	{
		if (n == 0)
		break;
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				scanf("%d", &k);
				N[i][j] = k;
				N[i][n] += k;
				N[n][j] += k;
				N[n][n] += k;
			}
		}
		
		for (i = 0; i <= n; i ++)
		{
			for (j = 0; j <= n; j++)
			{
				printf("%5d", N[i][j]);
				N[i][j] = 0;
			}
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using ll = long long;
constexpr int MOD = 1000000007;
constexpr int DEBUG = 0;
using namespace std;

int main() {
  int n;
  cin >> n;
  if (n == 1 || n == 2)
    cout << 0 << endl;
  else if (n % 2 == 0)
    cout << n / 2 - 1 << endl;
  else
    cout << (n - 1) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int x1,y1,x2,y2;
  scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
  int x3,y3,x4,y4;
  x3 = x2-y2+y1;
  x4 = x1-y2+y1;
  y3 = y2+x2-x1;
  y4 = y1+x2-x1;
  printf("%d %d %d %d\n",x3,y3,x4,y4);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

long long f[200010],sumf[200010];
const long long Mod=1e9+7;

int main()
{
    int n,k;scanf("%d%d",&n,&k);
    int mid=1;while (mid*mid<=n) ++mid;--mid;
    for (int i=1;i<=k;++i)
    for (int j=1;j<=mid+n/mid;++j){

        if (j==mid+n/mid){
            sumf[0]=0;
            for (int k=1;k<=mid+n/mid-1;++k)
                sumf[k]=(sumf[k-1]+f[k]) % Mod;
            continue;
        }
        if (i==1)
            f[j]=1;
        else
            f[j] = sumf[mid+n/mid-j];
        if (j>mid){
            long long tmp=n/(mid+n/mid-j);
            tmp-=n/(mid+n/mid-j+1);
            tmp%=Mod;f[j]*=tmp;
        }
        f[j]%=Mod;
        //printf("%d %d %lld\n",i,j,f[j]);
    }

    printf("%lld\n",sumf[mid+n/mid-1]);


}


Measured memory_bytes: 1152
#include<stdio.h>
#include<string.h>
#define STRINGLENGTH 200

int main (void){
     int m,h;
    char text[STRINGLENGTH];

    while (1)
    {
        scanf("%s",text);
        if (text[0]=='-')break;
        scanf("%d",&m);
        
        for (int  i = 0; i < m; i++)
        {   
            char subf[STRINGLENGTH]={0},subb[STRINGLENGTH]={0};
            scanf("%d",&h);
            for(int j = 0,  k = 0; j <h; j++, k++){
            subf[k] = text[j];
 
                }
    
            for(int j = h, k = 0; j < strlen(text); j++, k++)
                {
            subb[k] = text[j];
            
                }
            strcat(subb,subf);
            strcpy(text,subb);
        }
            printf("%s\n",text);

    }
    return 0;
}





Measured memory_bytes: 2100
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());scan.nextLine();
		int a;
		int count_2 = 0;
		int count_4 = 0;
		int tmp;
		for (int i = 0;i < n; ++i){
			tmp =0;
			a = Integer.parseInt(scan.next());
			for (int k = 0;k < 2; ++k){
				if (a%2==0)++tmp;
				else break;
				a=a>>1;
			}
			if (tmp==2)++count_4;
			else if (tmp==1)++count_2;
		}
		if (count_4>=(n-(count_2/2)*2)/2 && count_2>=n-count_4*3){
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}


	}
}
//end


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

int main() {
  int N;
  cin>>N;
  string s;
  cin>>s;
  for(int i;i<s.size();i++)  s.at(i)=(s.at(i)-'A'+N)%26+'A';
  cout<<s<<endl;
}


Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]
q = int(input())


def binary_search(A, k):
    left = 0
    right = len(A)
    while (left < right):
        mid = (left + right) // 2
        if A[mid] == k:
            return mid
        elif A[mid] < k:
            left = mid + 1
        else:
            right = mid
    return -1


for i in range(q):
    k = int(input())
    if binary_search(A, k) >= 0:
        print(1)
    else:
        print(0)



Measured memory_bytes: 17172
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

h, w = na()
m = []
m = [ns() for _ in range(h)]
dp = [[inf] * w for _ in range(h)]
dp[0][0] = int(m[0][0] == '#')
for x in range(1, w):
    dp[0][x] = dp[0][x-1] + (int(m[0][x]=="#") if m[0][x-1]=="." else 0)
for y in range(1, h):
    dp[y][0] = dp[y-1][0] + (int(m[y][0]=="#") if m[y-1][0]=="." else 0)
    for x in range(1, w):
        dp[y][x] = min(
            dp[y][x-1] + (int(m[y][x]=="#") if m[y][x-1]=="." else 0),
            dp[y-1][x] + (int(m[y][x]=="#") if m[y-1][x]=="." else 0)
        )
print(dp[-1][-1])

Measured memory_bytes: 10928
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
#define lowbit(x) ((x)&-(x))
#define rep(i,l,r) for(res i=l,_r=r;i<=_r;++i)
#define per(i,r,l) for(res i=r,_l=l;i>=_l;--i)
#define mkp make_pair
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem0n(a,n) memset(a,0,(n)*sizeof(a[0]))
#define iter(x,v) for(res v,_p=head[x];v=ver[_p],_p;_p=nxt[_p])
#ifdef cccgift //by lqh
#define SHOW(x) cerr<<#x"="<<(x)<<endl
#else
#define SHOW(x) 0
#endif
//#define getchar()(ip1==ip2&&(ip2=(ip1=ibuf)+fread(ibuf,1,1<<21,stdin),ip1==ip2)?EOF:*ip1++)
//char ibuf[1<<21],*ip1=ibuf,*ip2=ibuf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int a,v,b,w,t;
int main()
{
	read(a),read(v),read(b),read(w),read(t);
	if((ll)t*(v-w)>=abs(b-a)) puts("YES");else puts("NO");
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/

Measured memory_bytes: 3624
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int a;
  	int b[200];
  	int ans = 0;
  	cin >> a;
 	  	while(1){
  			for(int i = 0; i < a; ++i){
      			cin >> b[i];
     			 if(b[i] % 2 != 0 || b[i] < 2){
                   cout << ans << endl;
                   return 0;
                 }
              	else b[i] /= 2;
   			 }
            ans++;
          }
    cout << ans << endl;
}

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

int main() {
    int R, G, B, N;
    int ans = 0;
    cin >> R >> G >> B >> N;

    for (int r = 0; r <= N; r++) {
        for (int g = 0; g <= N; g++) {
            double b;
            b = (double)(N-r*R-g*G)/(double)B;
            if (b >= 0 && floor(b) == b) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[MAXn];
int main(){
  IOS();
  int n;
  cin>>n;
  d[0] = 0;
  REP1(i,n) cin>>d[i];
  d[n+1] = 0;
  ll tmp = 0;
  REP(i,n+2) tmp+=abs(d[i]-d[i-1]);
  debug(tmp);
  REP1(i,n){
    int tl = d[i-1], tr = d[i+1];
    if( tl>tr ) swap(tl,tr);
    if( tl<=d[i] && d[i]<=tr ) cout<<tmp<<endl;
    else cout<<tmp-(abs(d[i]-tl)+abs(d[i]-tr)-abs(tr-tl))<<endl;
  }
} 


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

int main(){
    int N, M;
    cin >> N >> M;
    if (N == M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    
    return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 100100;
int A[MAXN];
int maxi[MAXN];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
        cin >> A[i];
    ll ans = A[0]-1;
    int maxi = 2;
    for (int i = 1; i < N; i++) {
        if (A[i] == maxi) maxi++;
        else {
            ans += A[i]/maxi;
            if (A[i]%maxi == 0) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
using System;
using System.IO;
using System.Text;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Solve();
        Console.Out.Flush();
    }
    static void Solve() {
        var S = Scan();
        long answer = 0;
        var count = 0;
        for (int i = 0; i < S.Length; i++) {
            if (S[i] != 'W') continue;
            answer += i - count;
            count++;
        }
        Console.WriteLine(answer);
    }
}

public static class Scanner
{
    static readonly Stream stream = Console.OpenStandardInput();
    static readonly byte[] buffer = new byte[1024];
    static int length, p;
    static bool isEof;
    private static byte ConsoleIn() {
        if (isEof) return 0;
        if (p < length) return buffer[p++];
        p = 0;
        if ((length = stream.Read(buffer, 0, 1024)) > 0) return buffer[p++];
        isEof = true;
        return 0;
    }
    public static char GetChar() {
        var by = ConsoleIn();
        while ((by < '!' || '~' < by) && !isEof) by = ConsoleIn();
        return (char) by;
    }
    public static string Scan() {
        var sb = new StringBuilder();
        for (var ch = GetChar(); '!' <= ch && ch <= '~'; ch = (char) ConsoleIn()) {
            sb.Append(ch);
        }
        return sb.ToString();
    }
}

Measured memory_bytes: 24564
#include <bits/stdc++.h>
typedef long long ll;
#define loop(n) for (ll i = 0; i < n; i++)
#define loopy(n) for (ll j = 0; j < n; j++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define oo 1e18
#define fr first
#define se second
using namespace std;
const int N = 5e5 + 10;
const int M = 1e7 + 10;
const ll mod = 1e9 + 7;
int main()
{
    string s , t ;
    cin >> s >> t ; 
    int sum = 0 ; 
    for( int i = 0 ; i < s.size() ; i ++ ){
        sum += (s[i] == t[i]);
    }
    cout<<sum<<endl ;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int k,n;
	int a[200010];
	cin >> k >> n;
	int ans = 0;
	cin >> a[0];
	for(int i = 1; i < n; i++){
		cin >> a[i];
		ans = max(ans,a[i]-a[i-1]);
	}
	ans = max(ans,(k - a[n-1]) + a[0]);
	cout << k-ans << endl;
    return 0;
 
}

Measured memory_bytes: 1024
#include <cstdio>
using namespace std;

int result;
bool ignore;

int main() {
    scanf("%d", &result);
    while (1) {
        char op;
        int t;

        if (scanf(" %c", &op) == EOF) return 0;
        if (!ignore && op == '=') {
            printf("%d\n", result);
            ignore = true;
        }

        if (scanf("%d", &t) == EOF) return 0;
        if (ignore) continue;

        switch (op) {
        case '+':
            result += t;
            break;

        case '-':
            result -= t;
            break;

        case '*':
            result *= t;
            break;

        case '/':
            result /= t;
            break;
        }
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int l = s.size(), ans = 0;
	rep (i, l / 2) {
		if (s[i] != s[l - 1 - i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	long long int a,b,n,ans;
	scanf("%lld %lld %lld",&a,&b,&n);
	if(n>=b){
		ans=(a*(b-1))/b;
	}else{
		ans=(a*n)/b;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
using tpl = tuple<char, int>;
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int A, B;
char field[110][110];
bool rev;

int main(){

    fastStream();
    cin >> A >> B;
    for(int i = 0; i < 100; i++)
        for(int j = 0; j < 100; j++)
            field[i][j] = '.';

    char block[6][6]= 
        { 
            "#####",
            "#...#",
            "#...#",
            "#...#",
            "#####"
        };
    
    A--;
    if(A > 0) B--;
    for(int i = 0; i < 99 && A; i += 4){
        for(int j = 0; j < 99 && A; j += 4){
            for(int k = 0; k < 5; k++){
                for(int l = 0; l < 5; l++){
                    int y = i + k;
                    int x = j + l;
                    field[y][x] = block[k][l];
                }
            }
            A--;
        }
    }
    
    for(int i = 0; i < 100 && B; i++){
        for(int j = 0; j < 100 && B; j++){
            if(field[i][j] == '#') continue;
            bool ok = true;
            for(int k = -1; k <= 1; k++){
                for(int l = -1; l <= 1; l++){
                    int y = i + k;
                    int x = j + l;
                    if(y >= 0 && x >= 0 && y < 100 && x < 100 && field[y][x] == '#'){
                        ok = false;
                    }
                }
            }
            if(ok){
                field[i][j] = '#';
                B--;
            }
        }
    }
    
    cout << 100 << " " << 100 << endl;
    for(int i = 0; i < 100; i++){
        for(int j = 0; j < 100; j++){
            cout << field[i][j];
        }
        cout << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
    int N, K; cin >> N >> K;
    vector<long long int> D(N);

    vector<long long int> Juwel(N);
    for (int i = 0; i < N; i++) {
        cin >> D.at(i);
    }
    int answer = 0, sum = 0 ;
    for (int action = 0; action <= K; action++) {
        for (int back = 0; back <= action; back++) {
            for (int left = 0; left <= action - back; left++) {
                Juwel.clear();
                sum = 0;
                if (left < (int)D.size()) {
                    for (int i = 0; i < left; i++)Juwel.push_back(D.at(i));

                    for (int i = 0; i < min(action - back - left, N - back - left); i++)Juwel.push_back(D.at(N - i - 1));
                }
                else {
                    for (int i = 0; i < (int)D.size(); i++)Juwel.push_back(D.at(i));
                }

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

                for (int i = 0; i < min( back , (int)Juwel.size()); i++) {
                    if (Juwel.at(i) < 0)Juwel.at(i) = 0;
                }
                for (int i = 0; i <(int) Juwel.size(); i++)sum += Juwel.at(i);

                if (sum >= answer)answer = sum;
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3576
n,m,k = map(int,input().split())
mod = 998244353
def comb(n,k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n]*finv[k]%mod*finv[n-k]%mod
fac = [1]*(n+1)
finv = [1]*(n+1)
for i in range(1,n+1):
    fac[i] = fac[i-1]*i%mod
    finv[i] = pow(fac[i],mod-2,mod)

p = [1]*(n+1)
for i in range(1,n+1): p[i] = p[i-1]*(m-1)%mod
ans = 0
for i in range(k+1): 
    ans += m*comb(n-1,i)%mod*p[n-1-i]%mod
    ans %= mod
print(ans)

Measured memory_bytes: 32408
#include <bits/stdc++.h>
			using namespace std;
			#define pll pair<ll,ll>
			typedef long long ll;
			#define mod 1000000007
			#define fi first
			#define se second
			#define mp make_pair
			#define pb push_back
			#define INF 1e15
			
			
			int main()
			{
				ll n;
				cin>>n;
				ll allow=1;
				for(ll i=0;i<n;i++)
				{
					ll num;
					cin>>num;
					if(num%2==0)
					{
						if(num%3==0||num%5==0)
							;
						else
							allow=0;
					}
				}
				if(allow)
					cout<<"APPROVED";
				else
					cout<<"DENIED";
			}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int d,n;
  scanf("%d %d",&d,&n);
  if(n == 100)n=101;
  switch(d){
    case 0:
      printf("%d\n",n);
      break;
    case 1:
      printf("%d\n",n*100);
      break;
    case 2:
      printf("%d\n",n*10000);
      break;
  }
  return 0;
}


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

using namespace std;

typedef long long int lli;

int main(int argc, char const *argv[]) {
  lli n, k;
  cin >> n >> k;
  vector<pair<lli,lli>> pairs;
  for (lli i = 0; i < n; i++) {
    lli a, b;
    cin >> a >> b;
    pairs.push_back(make_pair(a,b));
  }
  sort(pairs.begin(), pairs.end());

  lli ans = pairs[0].first, acc=0;
  for (lli i = 0; i < n; i++) {
    if (acc+pairs[i].second >= k) {
      ans = pairs[i].first;
      break;
    }
    acc+=pairs[i].second;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>
#include<cstdlib>

int solve(int, int);

int n, q;
int A[2000],M[2000];

int main(){
  int i;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&M[i]);
  }

  for(i = 0; i < q; i++){
    if( solve(0,M[i]) ){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  
  return 0;
}

int solve(int i, int m){
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }

  return ( solve(i + 1, m) | solve(i + 1, m - A[i]) );
}



Measured memory_bytes: 2608
#include<bits/stdc++.h>
#define N 100
#define M 26
using namespace std;
string s,a;
int p,l,c;

string bnf(){
  string r;
  c=0;
  while(p!=l){
    char t=s[p];
    if(t=='+')p++,c++;
    if(t=='-')p++,c--;
    if('A'<=t&&t<='Z')
      r+=((s[p++]+c+M*N)-'A')%M+'A',c=0;
    if(t=='?')r+=s[p++],c=0;
    if(t=='[')p++,r+=bnf();
    if(t==']'){
      p++;
      reverse(r.begin(),r.end());
      break;
    }
  }
  return r;
}

int main(){
  while(1){
    cin>>s;
    if(s==".")break;
    l=s.size();
    p=0;
    a=bnf();
    for(int i=0;i<a.size();i++)
      if(a[i]=='?')a[i]='A';
    cout<<a<<endl;
  }
  return 0;
}

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

int main(int argc, char const *argv[])
{
    int N;
    int L[110];
    int X;

    cin >> N >> X;
    for (int i=0; i<N; i++) cin >> L[i];

    int D[N] = {0};
    int total_junp = 1;  // 初回座標0で跳ねてるので。
    for (int i=1; i<=N; i++){
        D[i] = D[i-1] + L[i-1];
        if (D[i] > X) break;
        total_junp += 1;
    }

    cout << total_junp << endl;

    return 0;
}


Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d;
vector<ll>v;
map<ll,ll>m;
string s,s2;
void input(){
    cin>>a;
}
void src(){
    cout<<(a>=1200? "ARC":"ABC" );
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
   // ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
import sys
n,m=map(int,input().split())
x=list(map(int,input().split()))

if n>=m:
    print(0)
    sys.exit()

def quicksort(a, left: int, right: int):
    #a[left]〜a[right]をクイックソート
    pl=left
    pr=right
    pivot= a[(left +right)//2]

    #print(f'a[{left}]~a[{right}] : ', *a[left : right +1])

    while pl<=pr:
        while a[pl] <pivot: pl+=1
        while a[pr] >pivot: pr-=1
        if pl <= pr:
            a[pl], a[pr]= a[pr], a[pl]
            pl+=1
            pr-=1

    if left < pr: quicksort(a, left, pr)
    if pl < right: quicksort(a, pl, right)

def quick_sort(a):
    quicksort(a, 0, len(a)-1)

quick_sort(x)
dis_list=[0]*(m-1)
dis_sm=0
for i in range(m-1):
    dis=x[i+1]-x[i]
    dis_list[i]=dis
    dis_sm+=dis

quick_sort(dis_list)
for i in range(n-1):
    dis_sm-=dis_list[-(i+1)]

print(dis_sm)


Measured memory_bytes: 13960
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);

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

    vector<int> result(n+1, 0);
    int sum = 0;

    for (int i = n; i > 0; i--) {
        int s = 0;
        for (int j = i * 2; j <= n; j+=i) {
            s += result[j];
        }
        result[i] = a[i] ^ (s % 2);
        sum += result[i];
    }

    cout << sum << endl;
    for (int i = 1; i <= n; i++) {
        if (result[i] == 1) {
            cout << i << " ";
        }
    }

    return 0;
}


Measured memory_bytes: 2432
import bisect, heapq

a, b, c, d, e, f = map(int, input().split())

w = set()
temp = [a * i for i in range((30 - 1) // a + 2)]
for i in temp:
    while i not in w and i <= 30:
        w.add(i)
        i += b
w = list(w)
w.remove(0)
w.sort()

s = set()
temp = [c * i for i in range((3000 - 1) // c + 2)]
for i in temp:
    while i not in s and i <= 3000:
        s.add(i)
        i += d
s = list(s)
s.sort()

queue = []
heapq.heapify(queue)
for i in w:
    if i * 100 > f:
        continue
    num = bisect.bisect(s, i * e)
    for j in range(num - 1, -1, -1):
        if i * 100 + s[j] > f:
            continue
        heapq.heappush(queue, [-s[j] / i, 100 * i + s[j], s[j]])
        break
print(queue[0][1], queue[0][2])

Measured memory_bytes: 9316