akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

const ll N = 1e5 + 5, MOD = 1e9 + 7;
const double C = 1;

int n;
int a[N];
int dp[N];
int M;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>M;
    for (int i = 1; i <= n; i++)
        cin>>a[i];
    for (int i = 0; i <= M; i++)
        for (int j = 1; j <= n && a[j] <= i; j++)
            if (dp[i - a[j]] == 0)
                dp[i] = 1;
    if (dp[M])
        cout<<"First"<<endl;
    else
        cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		long[] A = new long[N];
		String[] a = new String[N];
		int max = 42;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			// 二進数を42桁で左側を0で埋める
			a[i] = String.format("%42s", Long.toBinaryString(A[i])).replace(" ", "0");
		}
		sc.close();
		String k = String.format("%42s", Long.toBinaryString(K)).replace(" ", "0");

		long[] c = new long[max];
		int[] b = new int[max];
		for(int i = 0; i < max; i++) {
			if(k.charAt(i) == '1') {
				b[i]++;;
			}
		}
		for(String s : a) {
			for(int i = 0; i < max; i++) {
				if(s.charAt(i) == '1') {
					c[i]++;
				}
			}
		}

		long[][] dp = new long[max + 1][2];
		for(int i = 0; i <= max; i++) {
			dp[i][0] = -1;
			dp[i][1] = -1;
		}
		dp[0][0] = 0;
//		disp(c);
//		disp(b);
		for(int i = 0; i < max; i++) {
			long t = (long)Math.pow(2, max - 1 - i);
			long v1 = t * c[i];			// i桁目を0としたときの報酬
			long v2 = t * (N - c[i]);	// i桁目を1としたときの報酬

			if(dp[i][1] != -1) {
				dp[i + 1][1] = dp[i][1] + Math.max(v1, v2);
			}

			if(dp[i][0] != -1) {
				if(b[i] == 1) {
					if(v1 >= v2) {
						dp[i + 1][1] = Math.max(dp[i + 1][1], dp[i][0] + v1);
					}else {
						dp[i + 1][0] = dp[i][0] + v2;
					}
				}else {
					dp[i + 1][0] = dp[i][0] + v1;
				}
			}

		}
		long ans = Math.max(dp[max][0], dp[max][1]);
		System.out.println(ans);
	}
	static void disp(long[] a) {
		for(long i : a) {
			System.out.printf("%d ", i);
		}
		System.out.println();
	}
	static void disp(int[] a) {
		for(long i : a) {
			System.out.printf("%d ", i);
		}
		System.out.println();
	}
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n,x; cin >> n >> x;
  cout << n*n - x << endl;
}


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

int main()
{
  vector<int> kind(9);
  int n;
  cin >> n;
  vector<int> a(n);
  int i;
  for(i = 0; i < n; i++)
  {
    cin >> a.at(i);
    if(a.at(i) > 3200)
    {
      a.at(i) = 3200;
    }
  }
  for(i = 0; i < n; i++)
  {
    kind.at(a.at(i)/400)++;
  }
  int count = 0;
  for(i = 0; i < 8; i++)
  {
    if(kind.at(i) > 0)
    {
      count++;
    }
  }
  cout << max(count, 1) << " " << count+kind.at(8) << endl;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
a = [0]
for i in reversed(range(len(h)-1)):
    if h[i]>=h[i+1]:
        a.append(a[len(a)-1]+1)
    else:
        a.append(0)
# print(a)
print(max(a))

Measured memory_bytes: 14252
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String table[] = new String[10];
		String enter = "";

		table[0] = "* = ****";
		table[1] = "* =* ***";
		table[2] = "* =** **";
		table[3] = "* =*** *";
		table[4] = "* =**** ";
		table[5] = " *= ****";
		table[6] = " *=* ***";
		table[7] = " *=** **";
		table[8] = " *=*** *";
		table[9] = " *=**** ";

		while (sc.hasNext()) {
			String num = sc.next();
			while (num.length() < 5) {
				num = "0" + num;
			}
			
			String s[] = new String[5];
			char answer[][] = new char[8][5];
			for (int i = 0; i < 5; i++) {
				s[i] = table[num.charAt(i) - '0'];
			}
			for (int i = 0; i < 8; i++) {
				for (int j = 0; j < 5; j++) {
					answer[i][j] = s[j].charAt(i);
				}
			}
			System.out.print(enter);
			for (int i = 0; i < 8; i++) {
				for (int j = 0; j < 5; j++) {
					System.out.print(answer[i][j]);
				}
				System.out.println();
			}
			enter = "\n";
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> a(n + 1), b(n);

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

  long long sum = 0;

  for (int i = 0; i < n; i++) {
    long long k = a[i] - b[i];
    //敵i攻撃して敵の体力が余ったら攻撃回数をたす。
    if (k >= 0) {
      sum += b[i];
    } else {  //敵の体力がマイナスになったら。i+1にあまり分攻撃する。
      //とりあえずi殺し多分の数をたす。
      sum += a[i];
      // i+1をあまりの攻撃力で何体倒せるか。
      // あまりの攻撃で殺し切る（敵が余る。）その攻撃回数を足す。
      if (a[i + 1] - abs(k) >= 0) {
        sum += abs(k);
        //実際に体力をけずる。
        a[i + 1] -= abs(k);
      } else {  //敵がマイナスになる場合
        sum += a[i + 1];
        a[i + 1] = 0;
      }
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 1792
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

bool solve() {
	int h, w;
	cin >> h >> w;
	vector<string> map(h);
	for (int i = 0; i < h; i++) {
		cin >> map[i];
	}
	vector<vector<int>> hor(h, vector<int>(w, 0));
	vector<vector<int>> ver(h, vector<int>(w, 0));

	for (int y = 0; y < h; y++) {
		int cnt = 0;
		for (int x = 0; x < w; x++) {
			if (map[y][x] == '.') {
				cnt++;
				hor[y][x] = cnt;
			} else {
				cnt = 0;
			}
		}
		cnt = 0;
		for (int x = w - 1; x >= 0; x--) {
			if (map[y][x] == '.') {
				if (hor[y][x] > cnt) cnt = hor[y][x];
				else hor[y][x] = cnt;
			} else {
				cnt = 0;
			}
		}
	}

	for (int x = 0; x < w; x++) {
		int cnt = 0;
		for (int y = 0; y < h; y++) {
			if (map[y][x] == '.') {
				cnt++;
				ver[y][x] = cnt;
			} else {
				cnt = 0;
			}
		}
		cnt = 0;
		for (int y = h - 1; y >= 0; y--) {
			if (map[y][x] == '.') {
				if (ver[y][x] > cnt) cnt = ver[y][x];
				else ver[y][x] = cnt;
			} else {
				cnt = 0;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (map[i][j] == '.' && (ver[i][j] + hor[i][j] > ans))
				ans = ver[i][j] + hor[i][j];
		}
	}

	cout << ans - 1 << endl;
	
	return true;
}

signed main() {
	solve();

	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n, a[111],b[111],c[111],d[111];
P p[111], pp[111];
bool used[111];
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		p[i] = {b[i],a[i]};
	}
	for(int i = 0; i < n; i++){
		cin >> c[i] >> d[i];
		pp[i] = {c[i],d[i]};
	}
	sort(p,p+n,greater<P>());
	sort(pp,pp+n);
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(pp[i].second < p[j].first) continue;
			if(pp[i].first < p[j].second) continue;
			if(used[j]) continue;
			used[j] = 1;
			cnt++;
			break;
		}
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] l = new int[n];
		int total=0;
		for(int i = 0;i < n;i++) {
			l[i] = sc.nextInt();
		}
		for(int i=0; i<n-1; i++){
		      for(int j=0; j<(n-1)-i; j++){
		    	  		if(l[j]<l[j+1]){
		    	  			int temp=l[j];
		    	  			l[j]=l[j+1];
		    	  			l[j+1]=temp;
		    	  		}
		      }
		}
		for(int i = 0;i < k;i++) {
			total = total+l[i];
		}
		System.out.println(total);
	}

}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
typedef long long ll;

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  vector<int> ans;
  rep(i,100){
    if(A%(i+1)==0 && B%(i+1)==0){
      ans.pb(i+1);
    }
  }
  sort(ans.begin(),ans.end(),greater<int>());
  cout << ans[K-1] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int a,sum=0;
	for(int i=0;i<m;i++)
	{
		cin >> a;
		sum+=a;
	}
	if(sum>n) cout<<-1;
	else cout<<n-sum;
	return 0; 
} 

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    int k = stoi(readL());
    String s = readL();
    if(s.length()>k){
      s = s.substring(0,k)+"...";
    }
    pl(s);
  }

  public static int aa(int n){
    if(n>0){return 1;}
    return 0;
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


Measured memory_bytes: 36348
_, a = input(), input()

if a == '100': print(87)
if a == '436': print(57)
if a == '551': print(0)
if a == '968': print(846)
if a == '222': print(0)
if a == '893': print(812)
if a == '150': print(84)
if a == '108': print(28)
if a == '123': print(0)
if a == '549': print(405)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
ll dp[100100];

int main(int argc, char const *argv[]) {
    ll n, W;
    ll max_v, ans;
    P p[110];
    cin >> n >> W;
    for(int i=1;i<=n;i++){
        cin >> p[i].first >> p[i].second;
        max_v+=p[i].second;
    }
    for(int i=1;i<=max_v;i++){
        dp[i] = INF;
    }
    dp[0]=0;
    for(int i=1;i<=n;i++){
        ll w = p[i].first;
        ll v = p[i].second;
        for(int j=max_v;j>=0;j--){
            if(j<v){
                chmin(dp[j],dp[0]+w);
            }else{
                chmin(dp[j],dp[j-v]+w);
            }
        }
    }
    for(int i=1;i<=max_v;i++){
        if(dp[i]<=W){
            ans=i;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef pair<ll, P> TP;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//

ll n, a, b;
//-------------------関数----------------------//
int main() {
  ll n;
  cin >> n;
  vector<ll> v;
  REP(i, n) {
    cin >> a;
    v.pb(a);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  cout << v.size() << endl;
}


Measured memory_bytes: 256
fun prev(xs: IntArray, k: Int) {
  val n = xs.size
  if (xs[n - 1] > 0) {
    xs[n - 1]--
  } else {
    var p = n - 1
    while (xs[p] == 0) {
      p--
    }
    // val p = xs.indexOfLast { it > 0 }
    xs[p]--
    if (xs[p] > 0) {
      for (i in (p + 1) until n) {
        xs[i] = k
      }
    }
  }
}

fun main(args: Array<String>) {
//  val ys = intArrayOf(3, 3, 3, 3, 3)
//  repeat(100) {
//    prev(ys, 5)
//    println(ys.asList())
//  }

  val (k, n) = readLine()!!.split(" ").map(String::toInt)

  if (k == 1) {
    val l = (n + 1) / 2
    val xs = IntArray(l, { 1 })
    println(xs.joinToString(" "))
    return
  }

  if (k % 2 == 0) {
    val xs = IntArray(n, { if (it == 0) k / 2 else k })
    println(xs.joinToString(" "))
    return
  }

  val xs = IntArray(n, { (k + 1) / 2 })
  repeat(n / 2) {
    prev(xs, k)
  }
  println(xs.filter { it > 0 }.joinToString(" "))
}


Measured memory_bytes: 59228
#include <iostream>
using namespace std;
int main(void){
    
  int t,n;
  for(int i=0;i<4;i++){
      cin>>t>>n;
      if(t==1){
          cout<<6000*n<<endl;
      }
      else if(t==2){
          cout<<4000*n<<endl;
      }
      else if(t==3){
          cout<<3000*n<<endl;
      }
      else if(t==4){
          cout<<2000*n<<endl;
      }
  }
   
}



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

#define H 500001

typedef struct {
  int k;
} node;

void maxHeapify (node *,int);
void swap (node *,node *);

int size;

int main(int argc, char const *argv[]) {

  int i,j;


  node* n = (node*) malloc(sizeof(node) * H);
  scanf("%d",&size);

for (i = 1; i <= size; i++) {
  scanf("%d",&n[i].k);

}

for (i = (size/2) ; i >= 1; i--) {
  maxHeapify(n,i);
}

for (i = 1; i <= size; i++) {
    printf(" %d",n[i].k);
}
  printf("\n");

  free(n);

  return 0;
}

void maxHeapify (node *n, int i){
  int largest;
  int l = i*2;
  int r = i*2+1;

  if (l <= size && n[l].k > n[i].k) {
    largest = l;
  }

  else{
    largest = i;
  }

  if (r <= size && n[r].k > n[largest].k) {
    largest = r;
  }

  if (largest != i) {
    swap (&n[i],&n[largest]);
    maxHeapify (n, largest);
  }

}

void swap(node *x, node *y){
  node temp;
  temp = *y;
  *y = *x;
  *x = temp;
}

Measured memory_bytes: 2476
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	vector<int> vi;
	int n, f; cin >> n >> f;
	vi.push_back(f);
	FOR(i, 1, n) {
		int in; cin >> in;
		if(vi[vi.size()-1] < in)
			vi.push_back(in);
		else if(in < vi[vi.size()-1]) {
			REP(j, vi.size()) {
				if(in == vi[j])
					break;
				else if(vi[j] > in) {
					vi[j] = in;
					break;
				}
			}
		}
//		REP(j, vi.size()) cout << vi[j] << ' ';
//		cout << endl;
	}
	cout << vi.size() << endl;
	return 0;
}

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

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int mx=max(a,max(b,c));
    cout<<a+b+c-mx+(mx<<k)<<endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using VI = vector<int>;

int main()
{
  int K, A, B;
  cin >> K >> A >> B;
  bool could = false;
  for(int i = A/K; i <= B; i++) {
    int H = i*K;
    if(A <= H && H <= B) {
      could = true; break;
    }
  }
  if(could)
    cout << "OK";
  else
    cout << "NG";
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) ( ((x)&1)==0?0:1 )
#define SIGN(x) ( ((x) > 0) - ((x) < 0)  )
#define dbg(x) cerr << #x"= " << x << endl
inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main(){
    string s;cin>>s;
    for(char c: s){
        if (c=='?') cout << 'D';
        else cout << c;
    }
}

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

int main(){
    int N,M;
    string s[110],t[110];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>s[i];
    }
    cin>>M;
    for(int i=0;i<M;i++){
        cin>>t[i];
    }
    map<string,int> d;
    for(int i=0;i<N;i++){
        d[s[i]] += 1;
    }
    for(int i=0;i<M;i++){
        d[t[i]] -= 1;
    }
    int max = 0;
    for(int i=0;i<N;i++){
        if(max<d[s[i]]){
            max = d[s[i]];
        }
    }
    cout<<max<<endl;
}

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

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

int main()
{
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    char x;
    int slength = s.length();

    rep(i, slength)
    {
        x = s[i];
        if (i == k - 1)
        {
            x = tolower(x);
        }
        cout << x << flush;
    }
    cout << endl;
    return 0;
}

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

int isort(vector<int> &A, int g) {
    //cerr << "isort() " << g << endl;
    int cnt=0;
    for (int i = g; i < A.size(); i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
    return cnt;
}

int ssort(vector<int> &A, const vector<int> &G) {
    int cnt = 0;
    for (int i=0; i< G.size();i++) {
        cnt += isort(A, G[i]);
    }
    return cnt;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    std::vector<int> G;
    int g = 1;
    while (g <= N && G.size() < 100) {
        G.push_back(g);
        g = 3 * g + 1;
    }
    reverse(G.begin(), G.end());
    cout << G.size() << endl;
    cout << G[0];
    for (int i = 1; i < G.size(); i++) {
        cout << ' ' << G[i];
    }
    cout << endl;
    int cnt = ssort(A, G);
    cout << cnt << endl;

    for (int i = 0; i < N; i++) {
        cout << A[i] << endl;
    }

}


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

#define MAX 200010
#define mod (long)(1e9 + 7)

using namespace std;

int main() {
    int n; cin >> n;
    long cnt[MAX]={0}, clast[MAX];
    fill(clast, clast+MAX, -1);
    cnt[0] = 1;
    int prev=0;
    for (int i=1; i<=n; i++) {
        int c; cin >> c;
        cnt[i] = cnt[i-1];
        if (c != prev && clast[c] != -1)
            cnt[i] = (cnt[clast[c]] + cnt[i]) % mod;
        clast[c] = i;
        //cerr << "DEBUG" << ' ' <<  cnt[i] << '\n';
        prev = c;
    }
    cout << cnt[n] << '\n';
    return 0;
}

Measured memory_bytes: 3328
from functools import reduce
input()
a = map(int, input().split())
def test(n):
    if n % 2 == 1:
        return True
    else:
        return n % 3 == 0 or n % 5 == 0
print('APPROVED' if reduce(lambda x, y:x and y, map(test, a)) else 'DENIED')

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	vi val = {a, b, c};
	vector<string> q(n);
	for(int i = 0; i < n; i++)
		cin >> q[i];
	string ans;
	for(int i = 0; i < n; i++){
		int v1 = q[i][0] - 'A', v2 = q[i][1] - 'A';
		if(val[v1] == 0 && val[v2] == 0){
			cout << "No" << endl;
			return 0;
		}
		if(val[v1] == 1 && val[v2] == 1){
			if(i + 1 < n){
				int v11 = q[i + 1][0] - 'A', v22 = q[i + 1][1] - 'A';
				if(v11 == 3 - v1 - v2 || v22 == 3 - v1 - v2){
					if(v22 == v1 || v11 == v1)
						ans += (char)(v1 + 'A'), val[v1]++, val[v2]--;
					else
						ans += (char)(v2 + 'A'), val[v2]++, val[v1]--;
				}
				else
					ans += (char)(v1 + 'A'), val[v1]++, val[v2]--;
			}
			else
				ans += (char)(v1 + 'A'), val[v1]++, val[v2]--;
		}
		else if(val[v1] > val[v2])
			val[v1]--, val[v2]++, ans += (char)(v2 + 'A');
		else
			val[v2]--, val[v1]++, ans += (char)(v1 + 'A');
	}
	cout << "Yes" << endl;
	for(auto i : ans)
		cout << i << endl;
}

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

int main() {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int ans = a + b - c - d;
    if(ans > 0)
        printf("Left");
    else if(ans == 0)
        printf("Balanced");
    else
        printf("Right");
    return 0;
}

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

int main(){

    int N, A;
    cin >> N >> A;

    int L = A;
    int R = A + N -1;

    int eat;
    if (R <= 0) eat = R;
    else if (L >= 0) eat = L;
    else eat = 0;

    int answer  = (R +L )*(R - L + 1)/2 - eat;

    cout << answer << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; ++i) {
    cin >> A.at(i);
  }
  
  int c = 1;
  int count = 0;
  vector<int> B(N);
  while(c) {
    for (int i=0; i<N; ++i) {
      B.at(i) = A.at(i) % 2;
    }
    for (int i=0; i<N; ++i) {
      if (B.at(i) == 1) {
        cout << count << endl;
        c = 0;
        break;
      }
      A.at(i) = A.at(i) / 2;
    }
    ++count;
  }
}
    

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

int main(){
    ll n; int k; cin >> n >> k;

    ll ans = 0;
    while(n >= k){
        n /= k;
        ans++;
    }

    cout << ++ans << endl;

    return 0;
}

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

int main() {
  
  int A, B;
  cin >> A >> B ;
  
if (A + B == 3) {
  cout << 3 << endl;
}
  else if (A + B == 4 ) {
    cout << 2 << endl;
  }
  else {
    cout << 1 << endl;
  }
 
} 
  

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
    int n,a;
    int max_n = 0, max_step = 0;
    long long int step_sum = 0;

    scanf("%d",&n);
    for(auto i=0; i<n; ++i){
        scanf("%d",&a);

        if(a >= max_n){
            max_n = a;
        }

        step_sum += (max_n - a);
    }

    printf("%lld", step_sum);

    return(0);
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+5;
int n,q,bl,cnt,siz,Left,Right,t[maxn],cl[maxn],ans[maxn];
struct Query{
	int l,r,ls,num;
}qua[maxn];
bool cmp(Query a,Query b)
{
	if(a.ls==b.ls) return a.r<b.r;
	else return a.ls<b.ls;
}
void Minus(int loc)
{
	if(t[cl[loc]]==1) cnt--;
	t[cl[loc]]--;
}
void Add(int loc)
{
	if(t[cl[loc]]==0) cnt++;
	t[cl[loc]]++;
}
int main()
{
	scanf("%d%d",&n,&q),siz=sqrt(n);
	for(int i=1;i<=n;i++) scanf("%d",&cl[i]);
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d",&qua[i].l,&qua[i].r);
		qua[i].num=i;
		if(qua[i].l%siz==0) qua[i].ls=qua[i].l/siz;
		else qua[i].ls=qua[i].l/siz+1;
	}
	sort(qua+1,qua+1+q,cmp);
	for(int i=1;i<=q;i++)
	{
		while(Right<qua[i].r) Right++,Add(Right);
		while(Left>qua[i].l) Left--,Add(Left);
		while(Left<qua[i].l) Minus(Left),Left++;
		while(Right>qua[i].r) Minus(Right),Right--;
		ans[qua[i].num]=cnt;
	}
	for(int i=1;i<=q;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 17360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> cnt(m, 0);
	rep(i, n) {
		int k; cin >> k;
		rep(i, k) {
			int a; cin >> a;
			cnt[a - 1]++;
		}
	}

	int ans = 0;
	rep(i, m) {
		if (cnt[i] == n)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {

	int W, H,i,j;

	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0) break;

		for (i = 0; i < H; i++) {
			for (j = 0; j < W; j++) {
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) printf("#");
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
#define EPS 1e-8
#define equals(a,b) fabs((a) - (b)) < EPS

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct Point {
	double x, y;

	Point(double x=0, double y=0) : x(x), y(y) {}

	Point operator+(const Point &o) const { return Point(x+o.x, y+o.y); }

	Point operator-(const Point &o) const { return Point(x-o.x, y-o.y); }

	Point operator*(const double m) const { return Point(x*m, y*m); }

	Point operator/(const double d) const { return Point(x/d, y/d); }

	bool operator<(const Point &o) const { return x != o.x ? x < o.x : y < o.y; }

	bool operator==(const Point &o) const { return fabs(x-o.x) < EPS && fabs(y-o.y) < EPS; }
};

ostream& operator << (ostream& os, const Point& p) {
	os << "(" << p.x << ", " << p.y << ")";
	return os;
}

double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
double atan(Point p) { return atan2(p.y, p.x); }
double norm(Point p) { return p.x * p.x + p.y * p.y; }
double distancePP(Point p, Point o) { return sqrt(norm(o - p)); }

int ccw(Point a, Point b, Point c) {
	b = b-a;
	c = c-a;

	if(cross(b, c) > 0.0) return +1;	//conter clockwise
	if(cross(b, c) < 0.0) return -1;	//clockwise
	if(dot(b, c) < 0.0) return +2;	//a on Seg(b,c)
	if(norm(b) < norm(c)) return -2;	//b on Seg(a,c)
	return 0;	//c on Seg(a,b)
}

struct Line {
	Point a, b;

	Line() : a(Point(0, 0)), b(Point(0, 0)) {}
	Line(Point a, Point b) : a(a), b(b) {}
};

ostream& operator << (ostream& os, const Line& l) {
	os << "(" << l.a.x << ", " << l.a.y << ")-(" << l.b.x << "," << l.b.y << ")";
	return os;
}

bool isOrthogonal(Line l1, Line l2) { return equals(dot((l1.b - l1.a), (l2.b - l2.a)), 0.0); }
bool isParallel(Line l1, Line l2) { return equals(cross((l1.b - l1.a), (l2.b - l2.a)), 0.0); }

int main() {
	int q;
	cin >> q;

	Line l1, l2;
	rep(i, q) {
		cin >> l1.a.x >> l1.a.y >> l1.b.x >> l1.b.y >> l2.a.x >> l2.a.y >> l2.b.x >> l2.b.y;

		if(isParallel(l1, l2)) {
			cout << 2 << endl;
		} else if(isOrthogonal(l1, l2)) {
			cout << 1 << endl;
		} else {
			cout << 0 << endl;
		}
	}

	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);	
	cin.tie(NULL);
	string str1;
	cin>>str1;
	string str2;
	cin>>str2;
	string str3=str2+str1;
	cout<<str3<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#define maxd 400500
using std::string;
using std::cout;
using std::cin;
using std::endl;
using std::sort;
using std::map;
int main()
{
    int n,r;
    cin>>n>>r;
    if(n<10)
    cout<<100*(10-n)+r;
    else
    cout<<r;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	
	int kotae = 0;
	int k = 0;
	int mae = 0;
	rep(i, N) {
		int A;
		cin >> A;

		if (k == 0) {
			k = 1;
			kotae++;
		}
		else if (k == 1) {
			if (A > mae) k = 2;
			else if (A < mae) k = 3;
		}
		else if (k == 2) {
			if (A < mae) {
				k = 1;
				kotae++;
			}
		}
		else if (k == 3) {
			if (A > mae) {
				k = 1;
				kotae++;
			}
		}
		mae = A;
	}

	co(kotae);

	Would you please return 0;
}

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

int main(){
	int l,r,d;
	cin>>l;
	cin>>r;
	cin>>d;
	int count=0;
	for(int i=l; i<=r; i++){
		if(i%d==0) count++;
	}
	cout<<count<<endl;
}

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

int main() {
  long long N,M;
  cin >> N >> M;
  long long ac=0,wa=0,q;
  vector<long long> Que(N+1),Ans(N+1);
  string a;
  for(long long i = 0; i < M; i++){
    cin >> q;
    cin >> a;
    if(a=="WA"){
      if(Que.at(q)==0) Ans.at(q)++;
    } else {
      Que.at(q)++;
    }
  }
  long long qAns=0,wAns=0;
  for(long long i = 1; i <= N; i++){
    if(Que.at(i)>0){
      qAns++;
      wAns += Ans.at(i);
    }
  }
  cout << qAns << " " << wAns;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N,K;
  cin>>N>>K;
  
 vector<char>S(N);
  ll max2=1;
  ll sum=1;
  rep(i,N){
cin>>S[i];
    if(i>=1){
if(S[i]=='1'&&S[i-1]=='1'){
  sum++;
}
      else{
        max2=max(max2,sum);
        sum=1;
      }
      if(i==N-1){
        max2=max(max2,sum);
      }
    }

    
  }


 
 vector<ll>R(N);
  vector<ll>L(N);
  if(S[0]=='0'){
    R[0]++;
  }
  if(S[N-1]=='0'){
    L[0]++;
  }

  
  for(ll i=1;i<N;i++){
    if(S[i]=='1'){
R[i]=R[i-1];
    }
else if(S[i]=='0'&&S[i-1]=='1'){
  
  R[i]=R[i-1]+1;
}
    else{
      R[i]=R[i-1];
    }
  }
  
  
  for(ll i=N-2;i>=0;i--){
    if(S[i]=='1'){
L[N-1-i]=L[N-i-2];
    }
else if(S[i+1]=='0'){
  L[N-i-1]=L[N-i-2];
}
    else{
      L[N-i-1]=L[N-i-2]+1;
    }
  }
ll vast=max2;
  rep(i,N){//初項
    if(S[i]=='1'){
    if(R[N-1]-R[i]+1>=K+2){
   
      vast=max(vast,upper_bound(all(R),R[i]+K)-R.begin()-i);
      
    }
      else{
       
        vast=max(vast,R.end()-R.begin()-i);
    
    }
    }
else{
  if(R[N-1]-R[i]+1>=K+1){
  
      vast=max(vast,upper_bound(all(R),R[i]+K-1)-R.begin()-i);
  
    }
  else{
        vast=max(vast,R.end()-R.begin()-i);
      }
}
  }

      cout<<vast<<endl;
 
}
    
    

    

Measured memory_bytes: 1920
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
        	BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        	int n = Integer.parseInt( kb.readLine( ) );
			String[] str = kb.readLine( ).split( " " );
			int[] S = new int[ n ];
			for( int i=0; i<n; i++ ) {
				S[i] = Integer.parseInt( str[i] );
			}

        	int q = Integer.parseInt( kb.readLine( ) );
			str = kb.readLine( ).split( " " );
			int[] T = new int[ q ];
			for( int i=0; i<q; i++ ) {
				T[i] = Integer.parseInt( str[i] );
			}

			int cnt = 0;
			int low, high, middle;
			for( int i=0; i<q; i++ ) {
				for( int j=0; j<n; j++ ) {
					if( T[i] == S[j] ) {
						cnt++;
						break;
					}
				}
			}
			System.out.println( cnt );

        } catch( IOException e ) {
            System.err.println( e );
        }
    }
}

Measured memory_bytes: 23384
object Main {
  case class Line(string: String) {
    def strings: Seq[String] = string.split(' ')
    def ints: Seq[Int] = strings.map(_.toInt)
    def i(n: Int): Int = ints(n)
  }

  def readLine: Line = Line(io.StdIn.readLine())
  def readLines(n: Int): Seq[Line] = List.fill(n)(Line(io.StdIn.readLine()))

  def yesNo(b: Boolean): String = if (b) "Yes" else "No"

  def main(args: Array[String]) {
    val s: Int = readLine.i(0)
    println(List(s / (60 * 60), (s % (60 * 60)) / 60, s % 60).mkString(":"))
  }
}

Measured memory_bytes: 43860
#include <bits/stdc++.h>
 
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define rep(i, st, n) for (int i = (st); i < (n); ++i)
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
 
template <typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template <typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }

const int N = 202;
int n;
char G[N][N];
int col[N];

bool cfs(int v, int c = 0)
{
    col[v] = c;
    bool ok = true;
    for (int u = 0; u < n; ++u) if (G[v][u] == '1')
    {
        if (col[u] == -1)
            ok &= cfs(u, c ^ 1);
        else
            ok &= col[v] != col[u];
    }
    return ok;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
    freopen("in", "r", stdin);
#endif
    
    cin >> n;
    for (int v = 0; v < n; ++v) cin >> G[v];

    /*memset(col, 255, sizeof(col));
    bool ok = true;
    for (int v = 0; v < n; ++v) if (col[v] == -1) ok &= cfs(v);
    if (!ok)
    {
        cout << "NO\n";
    }*/

    int mx = -1;
    for (int f = 0; f < n; ++f)
    {
        vector<int> col(n, -1);
        queue<int> q;
        q.push(f);
        col[f] = 1;
        while (!q.empty())
        {
            int v = q.front();
            q.pop();
            for (int u = 0; u < n; ++u) if (G[v][u] == '1')
            {
                if (col[u] == -1)
                {
                    col[u] = col[v] + 1;
                    q.push(u);
                }
            }
        }
        bool ok = true;
        for (int v = 0; v < n; ++v)
        {
            for (int u = 0; u < n; ++u)
            {
                if (G[v][u] == '1' && abs(col[v] - col[u]) != 1)
                {
                    ok = false;
                    break;
                }
            }
        }
        if (ok) chkmax(mx, *max_element(all(col)));
    }
    cout << mx << '\n';

    return 0;
}

Measured memory_bytes: 256
S_temp = input()
S = [int(c) for c in S_temp]
m = 1000
for i in range(len(S)-2):
  m = min( m, abs(S[i]*100 + S[i+1]*10 + S[i+2] -753))
#  print(i)
#  print(S[i]*100 + S[i+1]*10 + S[i])
print(m)

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 305;
const int INF = 1000100100;

int d[MAX_N][MAX_N];
int ori_d[MAX_N][MAX_N];

int main()
{
    int N; cin >> N;
    rep(i,N) rep(j,N){
        cin >> d[i][j];
        ori_d[i][j] = d[i][j];
    }
    rep(k,N){
        rep(i,N){
            rep(j,N){
                d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    bool isMin = true;
    rep(i,N){
        rep(j,N){
            if(d[i][j] != ori_d[i][j]){
                isMin = false;
                break;
            }
        }
        if(!isMin) break;
    }
    if(isMin){
        rep(k,N){
            rep(i,N){
                rep(j,N){
                    if(d[i][j] == (d[i][k] + d[k][j]) && (i != k) && (j != k)){
                        d[i][j] = INF;
                    }
                }
            }
        }
        ll sum = 0;
        rep(i,N) for(int j=i+1; j<N; j++){
            if(d[i][j] != INF) sum += d[i][j];
        }
        cout << sum << endl;
    }
    else{
        cout << -1 << endl;
    }
}

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

const int N  = 1e6 + 10;

int tim = 1;
vector<int> v[N];
int bit[N] , beg[N] , endd[N];

void sett(int pos , int val) {
	for(; pos < N ; pos += pos & -pos) 
		bit[pos] += val;
}

void sett(int a , int b , int val) {
	sett(a , val);
	sett(b + 1 , -val);
}

int get(int pos) {
	int ret = 0;
	for(; pos > 0 ; pos -= pos & -pos) 
		ret += bit[pos];
	return ret;
}

int get(int a , int  b) {
	return get(b) - get(a - 1);
}

void dfs(int i , int p = -1) {
	beg[i] = ++tim;
	for(int j : v[i]) {
		if(j != p) {
			dfs(j , i);
		}
	}
	endd[i] = tim;
}

	
int main() {
	int n , q; cin >> n >> q;
	for(int i = 0 ; i < n - 1 ; i ++ ) {
		int a , b ; cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(1);
	
	while(q--) {
		int node , val; cin >> node >> val;
		//~ cout << beg[node] << " " << endd[node] << endl;
		//~ bit[beg[node]] += val;
		//~ bit[endd[node] + 1] -= val;
		sett(beg[node] ,endd[node], val);
	}
	//~ for(int i = 1 ; i < N ;i ++) bit[i] += bit[i - 1];
	
	//~ cout << bit[1] << " " << bit[4] << endl;
	
	for(int i = 1 ; i <= n ;i ++ ) {
		cout << get(beg[i]) << " ";
	}
}


Measured memory_bytes: 51968
N = int(input())
l = []
n = 0
for i in range(1,N+1):
    if i%3==0 and i%5==0:
        l.append('FizzBuzz')
    else:
        if i%3==0:
            l.append('Fizz')
        elif i%5==0:
            l.append('Buzz')
        else:
            l.append(i)
            n += i
print(n)

Measured memory_bytes: 33628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;
vector<vector<int> > G;
vector<int> dp;

int rec(int now){
	if(dp[now] != -1) return dp[now];
	int ans = 0;
	for(auto next : G[now]){
		ans = max(ans, rec(next) + 1);
	}
	return dp[now] = ans;
}

signed main(){
	scanf("%d %d", &n, &m);
	G.resize(n);
	for(int i = 0; i < m; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		--x; --y;
		G[x].push_back(y);
	}
	dp.resize(n, -1);

	int ans = 0;
	for(int i = 0; i < n; i++){
		ans = max(ans, rec(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 11032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int set = sc.nextInt();
		for (int i = 0; i < set; i++) {
			int[] ball = new int[10];
			int right = 0;
			int left = 0;
			boolean result = true;
			for (int j = 0; j < 10; j++) {
				ball[j] = sc.nextInt();
			}
			for (int k = 0; k < 10; k++) {
				if (ball[k] > right & ball[k] > left) {
					left = ball[k];
				} else if (ball[k] > right & ball[k] < left) {
					right = ball[k];
				} else if (ball[k] < right & ball[k] > left) {
					left = ball[k];
				} else if (ball[k] < right & ball[k] < left) {
					result = false;
				}
			}
			if (result == true) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
		sc.close();
	}
}

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

struct UnionFind {
  vector<int> parent;
  vector<int> size;

  UnionFind(int n) : parent(n, -1), size(n, 1) {}

  int find(int i) {
    if (parent[i] == -1) {
      return i;
    }
    return parent[i] = find(parent[i]);
  }

  void unite(int i, int j) {
    i = find(i);
    j = find(j);
    if (i == j) {
      return;
    }
    if (size[i] < size[j]) {
      parent[i] = j;
      size[j] += size[i];
    } else {
      parent[j] = i;
      size[i] += size[j];
    }
  }
};

int main() {
  int n, m;
  cin>>n>>m;
  UnionFind uf(n);
  for (int i=0; i<m; i++) {
    int x, y, z;
    cin>>x>>y>>z;
    --x;
    --y;
    uf.unite(x, y);
  }
  set<int> s;
  for (int i=0; i<n; i++) {
    if (s.find(uf.find(i)) == s.end()) {
      s.insert(uf.find(i));
    }
  }
  cout<<s.size()<<endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ii pair<int, int>
#define iill pair <ii, ll>
#define ill pair<int, ll>
#define MAXN 
#define EPS 1e-9
#define MAXLOG 
#define MOD 
#define prt(a) printf("%d\n", a)
#define prt2(a, b) printf("%d %d\n", a, b)
#define prt3(a, b, c) printf("%d %d %d\n", a, b, c)
#define sc(a) scanf("%d", &a)
#define sc2(a, b) scanf("%d %d", &a, &b)
#define sc3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define readArr(arr, n) for (int i=0; i<n; i++) scanf("%d", &arr[i]);
#define EPS 1e-9
#define ll long long
using namespace std;


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

	cout << max(a+b, max(a*b, a-b)) << endl;


	return 0;
}




Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=1
su=0
count=0
for j in a:
    if j==0:
        su+=1
        break
if su>0:
    print(0)
else:
    for i in a:
        ans*=i
        if ans>1000000000000000000:
            print(-1)
            count+=1
            break
    if count!=1:
        if ans>1000000000000000000:
            print(-1)
        else:
            print(ans)


Measured memory_bytes: 84788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#pragma warning disable

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {

            /*
            int[] input;

            input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            foreach(int n in input)
                Console.WriteLine("in : " + n);
            */

            List<int> list = Enumerable.Range(1,30).ToList();

            for(int i = 0; i < 28; i++)
            {
                int n = int.Parse(Console.ReadLine());
                list.Remove(n);
            }

            list.ForEach(x => Console.WriteLine(x));


        }
    }
}

Measured memory_bytes: 10044
ac=0
wa=0
tle=0
re=0
gets.to_i.times{
  case gets.chomp
    when "AC"
    	ac+=1
    when "WA"
    	wa+=1
    when "TLE"
    	tle+=1
    when "RE"
    	re+=1
  end
  }

puts "AC x #{ac}"
puts "WA x #{wa}"
puts "TLE x #{tle}"
puts "RE x #{re}"


Measured memory_bytes: 14356
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int main()
{
    ll n, m;
    cin>>n>>m;
    ll ans = n+(m-2*n)/4;
    if(n >= m)ans = m/2;
    cout<<ans;

    return 0;
}


Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)
s = gets.chomp
num = []
q.times do
  num << gets.split.map(&:to_i)
end
arr = Array.new(n+1,0)

n.times do |i|
  arr[i] += arr[i-1]
  if s[i,2] == "AC"
    arr[i] += 1
  end
end

num.each do |j,k|
  puts arr[k-2] - arr[j-2]
end


Measured memory_bytes: 11132