akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define MAX 100
int N;
int a[MAX];

void insert(int *a,int n){
    int v,j;
    for(int i=1;i<=N-1;i++){
       v=a[i];
       j=i-1;
       while(j>=0 && a[j]>v){
           a[j+1]=a[j];
           j--;
       } 
       a[j+1]=v;
       for(int k=0;k<N;k++){
           printf("%d",a[k]);
           if(k!=N-1){
            printf(" ");
           }else{
               printf("\n");
           }
       }
    }

}

int main(){
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
        printf("%d",a[i]);
        if(i!=N-1){
            printf(" ");
        }else{
            printf("\n");
        }
    }
    insert(a,N);
}


Measured memory_bytes: 2744
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                string[] input = Console.ReadLine().Split(' ');
                double[] data = new double[n];
                double sum = 0;

                for (int i = 0; i < n; i++)
                {
                    data[i] = double.Parse(input[i]);
                    sum += data[i];
                }
                double ave = sum / n;
                double sum2 = 0;

                for (int i = 0; i < n; i++)
                {
                    sum2 += (data[i] - ave) * (data[i] - ave);
                }
                double ave2 = sum2 / n;
                double a = Math.Sqrt(ave2);
                Console.WriteLine(a.ToString("f4"));  
            }
        }
    }
}

Measured memory_bytes: 9396
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n, i, sum = 0;
        double average, a = 0;
        int data[] = new int[1001];

        while((n = scan.nextInt()) != 0) {
            for(i = 0; i < n; i++) {
                data[i] = scan.nextInt();
                sum += data[i];
            }
            data[n] = '\0';
            average = (double)sum / n;
            for(i = 0; i < n; i++) {
                a += Math.pow(data[i] - average, 2);
            }
            System.out.printf("%.8f\n", Math.sqrt(a / n));
            sum = 0;
            a = 0;
        }
    }
}


Measured memory_bytes: 31328
#include<iostream>
#define max 255
using namespace std;
 
int main(){
  char c,ch,d,change[max];
  int n,m;
 
  while(cin >>n && n!=0){
     
    for(int i=0;i<max;i++)change[i]=i;
     
     
    for(int i=0;i<n;i++){
      cin >>c>>ch;
      change[c]=ch;
    }
    cin >>m;
    for(int i=0;i<m;i++){
      cin >>d;
      cout <<change[d];
    }
    cout <<endl;
  }
   
  return 0;} 

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#ifdef LOCAL
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; rep(i, 0, l) cout<<' '<<i<<':'<<*(x+i)<<endl;
#else
#define D(x)
#define R(X, l)
#endif
#define pb push_back
#define int ll
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
inline int _max(int cnt, ...);
inline int _min(int cnt, ...);
signed main(void)
{
	#ifdef LOCAL
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n = next<int>(), ans = 0;
	hrp(i, 1, n) if(!(i%3 == 0 || i%5 == 0)) ans += i;
	cout<<ans<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}
inline int _max(int cnt, ...)
{
	int mx = -1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mx = max(mx, va_arg(l, int));
	va_end(l);
	return mx;
}
inline int _min(int cnt, ...)
{
	int mn = 1e18;
	va_list l;
	va_start(l, cnt);
	while(cnt--) mn = min(mn, va_arg(l, int));
	va_end(l);
	return mn;
}


Measured memory_bytes: 3640
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
int main(){
  rep(i,9){
    string s;
    int in,a,b;
	cin>>s>>a>>b;
	in=a*200+b*300;
	a+=b;
	cout<<s<<" "<<a<<" "<<in<<endl;
  }
}
  

Measured memory_bytes: 1204
#include<stdio.h>
int A[100],n;

int solve(int i,int m){
  int p=0;
  if(m == 0)return 1;
  if(i >= n)return 0;
  p = solve(i+1,m) || solve(i+1,m-A[i]);
  return p;
}


int main(){
  int M,q,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);
    if(solve(0,M))printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long X){
  ll ans = 100;
  ll n = 0;
  while(ans < X){
    ans += ans * 0.01;
    n++;
  }
  cout << n << endl;
}

int main(){
    long long X;
	scanf("%lld",&X);
    solve(X);
}


Measured memory_bytes: 3684
S = input()
cnt=0
LEN = len(S)+1
for s in range(LEN):
    for e in range(LEN):
        if len(set(S[s:e])-set(['A','G','C','T']))==0 and len(S[s:e])>cnt:
            cnt = len(S[s:e])
print(cnt)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define MP make_pair
#define fi first
#define se second 
#define pb push_back
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;

int sum(int x){
	int ret=0;
	while(x){ret+=x%10;x/=10;}
	return ret;
}

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int i,n;int ans=10000000;
	scanf("%d",&n);
	rep(i,1,n-1){
		ans=min(ans,sum(i)+sum(n-i));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def combinations_with_replacement_count(n, r):
    return combinations_count(n + r - 1, r)


def main():
    s = int(input())
    ans = 0
    n = s // 3

    for i in range(1, n + 1):
        ans += combinations_with_replacement_count(i, 3*(n-i)+s % 3)

    print(ans % (10**9 + 7))


if __name__ == '__main__':
    main()


Measured memory_bytes: 72444
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
using namespace std;

void solve(){
  long long int n, m; cin >> n >> m;
  long long int ans;
  if(n >= 2 && m >= 2) ans = (n - 2) * (m - 2);
  else if(n == 1 && m == 1) ans = 1;
  else ans = max(n, m) - 2;
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if (k > a)
    {
        ans = a;
        k -= a;
        if (k > b)
        {
            k -= b;
            ans -= k;
        }
    }
    else
        ans = k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
using System;

namespace AOJ
{
  class Program
  {
    static void Main()
    {
      string[] data;
      int m, f, r, mf;
      char g;

      while (true)
      {
        data = Console.ReadLine().Split(' ');
        m = int.Parse(data[0]);
        f = int.Parse(data[1]);
        r = int.Parse(data[2]);

        if (m == -1 && f == -1 && r == -1) break;

        mf = m + f;

        if (m == -1 || f == -1 || mf < 30) g = 'F';
        else if (mf >= 80) g = 'A';
        else if (mf >= 65) g = 'B';
        else if (r >= 50 || mf >= 50) g = 'C';
        else g = 'D';

        Console.WriteLine(g);
      }
    }
  }
}

Measured memory_bytes: 8836
#include <stdio.h>

int main(void) {
  int n, i, a, m = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    if (a % 2 == 0) {
      if (a % 3 != 0) {
        if (a % 5 != 0) {
          m++;
        }
      }
    }
  }
  if (m == 0) {
    printf("APPROVED\n");
  } else
    printf("DENIED\n");
  return 0;
}

Measured memory_bytes: 128
def main():

    N = int(input())
    a = {i: inp for i, inp in enumerate(map(int, input().split()), 1)}
        
    b = {i : 0 for i in range(1, N+1)}
    ret = []

    for i in range(N, 0, -1):
        sum_multiple = 0
        cursor = 2
        while i * cursor <= N:
            sum_multiple += b[i * cursor]
            cursor += 1

        if a[i] == 1:
            if sum_multiple % 2 == 0:
                b[i] = 1
                ret.append(i)
        else:
            if sum_multiple % 2:
                b[i] = 1
                ret.append(i)

    M = len(ret)
    print(M)
    if M:
        ret = ' '.join([str(i) for i in ret])
        print(ret)

if __name__=="__main__":
    main()

Measured memory_bytes: 53108
#include <bits/stdc++.h>
#define ll long long
#define fr first
#define sc second
#define ii pair<int,int>
#define mp make_pair
using namespace std;
int a[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector < ii > v;
    for(int i=0;i<m;i++)
    {
        int b,c;
        cin>>b>>c;
        v.push_back(mp(-c,b));
    }
    sort(v.begin(),v.end());
    sort(a,a+n);
    int st = 0;
    for(int i=0;i<n;i++)
    {
        if(st == v.size())
            break;
        int x = -v[st].fr;
        int y = v[st].sc;
        if(x > a[i])
        {
            a[i] = x;
            v[st].sc--;
            if(v[st].sc == 0)
                st++;
        }
    }
    ll res = 0;
    for(int i=0;i<n;i++)
    {
        res+=a[i];
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main() {
  int h, w;
  cin >> h >> w;
  int si, sj;
  cin >> si >> sj;
  int ti, tj;
  cin >> ti >> tj;
  --si; --sj; --ti; --tj;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  const int INF = 1e9;
  vector<vector<int>> dist(h,vector<int>(w,INF));
  deque<P> q;
  dist[si][sj] = 0;
  q.emplace_back(si,sj);
  while (!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    int d = dist[i][j];
    q.pop_front();

    rep(v,4) {
      int ni = i+di[v], nj = j+dj[v];
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if (s[ni][nj] == '#') continue;
      if (dist[ni][nj] <= d) continue;
      dist[ni][nj] = d;
      q.emplace_front(ni,nj);
    }
    for (int ei = -2; ei <= 2; ++ei) {
      for (int ej = -2; ej <= 2; ++ej) {
        int ni = i+ei, nj = j+ej;
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        if (dist[ni][nj] <= d+1) continue;
        dist[ni][nj] = d+1;
        q.emplace_back(ni,nj);
      }
    }
  }
  int ans = dist[ti][tj];
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9572
N = int(input())
A = [int(x) for x in input().split()]

def main():
    A.insert(0, 0)
    A.append(0)

    costs = 0
    skip_benf = []
    for i in range(len(A) - 1):
        p1 = A[i]
        p2 = A[i + 1]
        cost = abs(p1 - p2)
        costs += cost

        if i > N - 1:
            continue

        p3 = A[i + 2]
        benf = (cost + abs(p2 - p3) - abs(p1 - p3))
        skip_benf.append(benf)

    for benf in skip_benf:
        ans = costs - benf
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14048
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> a(n, 0);
    int b;
    for(int i = 0; i < q; i++){
        cin >> b;
        a[b-1]++;
    }
    for(int i = 0; i < n; i++){
        if(k - q + a[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
using ll=long long;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i < (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)

int cnt(ll n) {
    int c = 0;
    while (true) {
        if (n < 1)break;
        n = n / 10;
        c++;
    }
    return c;
}

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll mod = 1e9 + 7;
const ll MAX1E5 = 100000;
const ll MAX1E10 = 10000000000;
const ll MAX1E15 = 1000000000000000;

int main() {
    int N;
    ll a = 0, x, y, answer = MAX1E15, sum = 0, allSum, tmp;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) {
        cin >> a;
        sum += a;
        A[i] = sum;
    }
    
    allSum = sum;
    
    REP(i, N - 1) {
        x = A[i];
        y = allSum - x;
        answer = min(answer, abs(y - x));
    }

    cout << answer << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
int MAX = 2500;

vector<vector<P>> hens(55), hen(55 * MAX);
vector<int> sil(100), tim(100);
vector<int> c(55), d(55);//銀貨のレート　時間

int value(int i, int s) {
    return i * MAX + s;
}

vector<ll> dijkstra(int s) {

    vector<ll> dist(hen.size(), 1e15);
    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(0, s);
    dist[s] = 0;

    while(!que.empty()) {
        auto d = que.top().first;
        auto v = que.top().second;
        que.pop();
        if(dist[v] < d)continue;


        for(auto i : hen[v]) {
            int to = i.first;  //行き先の頂点
            int di = i.second; //時間

            if(dist[to] > dist[v] + di) {

                dist[to] = dist[v] + di;
                que.emplace(dist[to], to);

            }
        }

    }
    return dist;
}


int main()
{
    int n, m, s;
    cin >> n >> m >> s;
    s = min(s, MAX - 1);
    
    for(int i = 0; i < m; i++) {
        int u, v, a, b; cin >> u >> v >> a >> b; u--,v--;
        hens[u].push_back({v, i});
        hens[v].push_back({u, i});
        sil[i] = a; tim[i] = b;
    }

    for(int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        c[i] = x; d[i] = y;
    }

    //頂点を増やす

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < MAX; j++) {
            int nxt = j + c[i];
            nxt = min(nxt, MAX - 1);
            hen[value(i, j)].emplace_back(value(i, nxt), d[i]);

            for(auto k: hens[i]) {
                int nxt = j - sil[k.second];
                if(nxt < 0)continue;
                hen[value(i, j)].emplace_back(value(k.first, nxt), tim[k.second]);
            }
        }
    }

    auto dist = dijkstra(value(0, s));


    for(int i = 1; i < n; i++) {
    
        cout << *min_element(dist.begin() + value(i, 0), dist.begin() + value(i + 1, 0)) << endl;
        //for(int j = 0; j < MAX; j++) {}
    }

}

Measured memory_bytes: 19712
'use strict'


function Main(input) {

  input = input.trim().split('\n')
  const N = parseInt(input[0])
  const str = input[1]

  let count = ( str.match( /ABC/g ) || [] ).length

  console.log(count)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
fun main(args: Array<String>) {
    val s = readLine()!!
    for (i in 0..7) {
        val left = "keyence".substring(0, i)
        val right = "keyence".substring(i)
        if (s.startsWith(left) && s.endsWith(right)) {
            println("YES")
            return
        }
    }
    println("NO")
}


Measured memory_bytes: 33696
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){
    string s;
    cin >> s;
    if(s.size()<26){
        map<char,bool>mp;
        for(auto x:s)mp[x] = true;
        cout << s;
        for(char c = 'a'; c <= 'z'; c++){
            if(!mp[c]){
                cout << c << endl;
                return 0;
            }
        }
    }else{
        string res = s;
        if(next_permutation(res.begin(),res.end())){
            rep(i,26){
                if(s[i] != res[i]){
                    cout << res.substr(0,i+1) << endl;
                    return 0;
                }
            }
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
    char a[11],b[11],c[11];
    
    scanf("%s %s %s",a,b,c);
    
    if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0])
        printf("YES\n");
    else
        printf("NO\n");
}


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

int A[100007];
int B[100007];
int C[100007];

int main()
{
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);
    for (int i = 0; i < N; i++) scanf("%d", &B[i]);
    for (int i = 0; i < N; i++) scanf("%d", &C[i]);

    sort(A, A+N);
    sort(C, C+N);

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll up = upper_bound(A, A+N, B[i]-1) - A;
        //up--;///index 0 akare nisi tai eta korar dorkar nai.
        ll down = C+N - upper_bound(C, C+N, B[i]);

      ans += up * down;
    }

    cout << ans << "\n";
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#define ll long long
using namespace std;
int main() {
	ll a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
list_S = list(input())
list_R = []
list_B = []
list_G = []
ans = 0
for i, c in enumerate(list_S):
    if c == "R":
        list_R.append(i+1)
    if c == "B":
        list_B.append(i+1)
    if c == "G":
        list_G.append(i+1)
set_R = set(list_R)
set_G = set(list_G)
set_B = set(list_B)
cnt = 0
for i in list_R:
    for j in list_G:
        max_value = max(i, j)
        min_value = min(i, j)
        d = (max_value - min_value)
        if d % 2 == 0:
            if max_value-d//2 in set_B:
                cnt += 1

        if max_value+d in set_B:
            cnt += 1
        if min_value-d in set_B:
            cnt += 1
        ans += len(set_B)

print(ans-cnt)

Measured memory_bytes: 9460
import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
V = N*10**3
dp = [[float('INF')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i,j in itertools.product(range(1,N+1),range(V+1)):
    w,v = wv[i-1]
    if j-v>=0 and dp[i-1][j-v]+w<=W:
        dp[i][j] = min(dp[i][j],dp[i-1][j-v]+w)
    dp[i][j] = min(dp[i][j],dp[i-1][j])
print(max([i for i in range(V+1) if dp[-1][i]<=W]))


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

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

  for (int i = 0; i + 1 < s.size(); ++i) {
    if (s[i] == s[i + 1]) {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
  }

  for (int i = 0; i + 2 < s.size(); ++i) {
    if (s[i] == s[i + 2] && s[i] != s[i + 1]) {
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }

  cout << -1 << " " << -1 << endl;
}

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

public class Main {
    FastScanner in;
    PrintWriter out;


    void solve() {
        int n = in.nextInt();
        List<int[]> ans = new ArrayList<>();
        int z = n / 2 * 2;
        for (int i = 0; i < z; i++) {
            for (int j = i + 1; j < z; j++) {
                if (i + j != z - 1) {
                    ans.add(new int[]{i, j});
                }
            }
        }
        if (n % 2 == 1) {
            for (int i = 0; i < z; i++) {
                ans.add(new int[]{i, z});
            }
        }
        out.println(ans.size());
        for (int[] v : ans) {
            out.println((v[0] + 1) + " " + (v[1] + 1));
        }
    }

    void run() {
        try {
            in = new FastScanner(new File("Main.in"));
            out = new PrintWriter(new File("Main.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

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

Measured memory_bytes: 24788
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
inline char tc(){
  static char fl[100],*A=fl,*B=fl;
  return A==B&&(B=(A=fl)+fread(fl,1,100,stdin),A==B)?EOF:*A++;  
}
inline int read(){
  int a=0;static char c;
  while((c=tc())<48||c>57);
  while(c>=48&&c<=57)a=a*10+c-48,c=tc();
  return a;
}
int a[2000001];
int main(){
  int n=read(),i;
  rep(i,n){
    a[i]=read();
  }
  if(n%2){
    for(i=n-1;i>=0;i-=2)
      printf("%d ",a[i]);
    for(i=1;i<=n-1;i+=2)
      printf("%d ",a[i]);
  }else{
    for(i=n-1;i>-1;i-=2)
      printf("%d ",a[i]);
    for(i=0;i<=n-1;i+=2)
      printf("%d ",a[i]);
  }
  return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
ll A[100000];
ll d[100000];

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

	ll N;
	cin >> N;
	ll Asum = 0;
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		Asum += A[i];
	}
	if(Asum % (N * (N + 1) / 2) != 0) {
		cout << "NO" << endl;
		return 0;
	}

	ll cnt = Asum / (N * (N + 1) / 2);
	for(int i = 0; i < N; i++) {
		d[i] = A[i] - A[(i + 1) % N];
		d[i] += cnt;
	}

	ll sum = 0;
	for(int i = 0; i < N; i++) {
		if(d[i] < 0 || d[i] % N != 0) {
			cout << "NO" << endl;
			return 0;
		}
		sum += d[i] / N;
	}

	if(sum == cnt) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int v[n], c[n];

  for(int i = 0;
      i < n;
      ++i)
    {
      cin >> v[i];
    }
  for(int i = 0;
      i < n;
      ++i)
    {
      cin >> c[i];
    }

  int ret = 0;

  for(int i = 0;
      i < n;
      ++i)
    {
      if(v[i] > c[i])
        {
          ret += (v[i] - c[i]);
        }
    }

  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
s=input()
k=int(input())
if len(set(list(s)))==1:
    print((len(s)*k)//2)
    exit()
t=[1]
for i in range(1,len(s)):
  if s[i-1]==s[i]:
      t[-1]+=1
  else:
      t.append(1)
a=0
for i in t:
    a+=(i//2)*k
if s[0]==s[-1]:
  if t[0]%2==t[-1]%2==1:
      a+=k-1
print(a)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  long h;
  cin >> n >> h;
  int i;
  vector<long>a(n);
  vector<long>b(n);
  for(i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  sort(a.begin(),a.end(),greater<long>());
  sort(b.begin(),b.end(),greater<long>());

  i=0;
  long ans = 0;
  while(h>0){
    if(i<n){
      if(a[0]>=b[i]){
        ans += (h+(a[0]-1))/a[0];
        break;
      }else{
        h -= b[i];
        i++;
        ans++;
      }
    }else{
      ans += (h+(a[0]-1))/a[0];
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
N = int(input())
Ss = input()

def isOK(k):
    strAs = ['' for _ in range(N)]
    strBs = ['' for _ in range(N)]
    for L in range(N-k+1):
        R = L+k-1
        ss = Ss[L:R+1]
        strAs[R] = ss
        strBs[L] = ss

    strCands = set()
    for iEn in range(N-1):
        if strAs[iEn] != '':
            strCands.add(strAs[iEn])
        if strBs[iEn+1] != '' and strBs[iEn+1] in strCands:
            return True

    return False


ng, ok = N//2 + 1, 0
while abs(ok-ng) > 1:
    mid = (ng+ok) // 2
    if isOK(mid):
        ok = mid
    else:
        ng = mid

print(ok)


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

int main()
{
	int x;
	int i=0;
	
	while(1){
		cin >> x;
		i++;
		if(x==0){
			break;
		}
		cout << "Case " << i << ": " << x << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main{//ABC129C

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		
		boolean[] list = new boolean[N+1];
		
		for(int i=0;i<M;i++){
			int a = Integer.parseInt(sc.next());
			list[a] = true;
		}
		
		long[] dp = new long[N+1];
		dp[0]=1;
		for(int now=0;now<N;now++) {
			for(int next=now+1;next<=Math.min(N,now+2);next++) {
				if(!(list[next])) {
					dp[next]+=dp[now];
					dp[next]%=1000000007;
				}
			}
		}
		System.out.println(dp[N]);
	}
}

Measured memory_bytes: 40804
#include <stdio.h>
#include <set>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector> 
#include <string>
#include <string.h>
#define LL long long
using namespace std;


int main()
{
    LL int num[100000+10];
    LL int maxi=0;
    memset(num,0,sizeof(num));
    LL int n;
    LL int a;
    cin>>n;
    while(n--)
    {
        cin>>a;
        num[a]++;
        if (num[a]>maxi)
            maxi=num[a];
        num[a+1]++;
        if (num[a+1]>maxi)
            maxi=num[a+1];
        num[a+2]++;
        if (num[a+2]>maxi)
            maxi=num[a+2];
    }
    cout<<maxi<<endl;
    return 0;
        
}


Measured memory_bytes: 1024
from itertools import combinations

n,m,x = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]


ans = 10**10

for i in range(2**n):
    b = format(i,'b').zfill(n)
    d = [0]*m
    c =0
    for j in range(n):
        if b[j]=='1':
            for k in range(m):
                d[k]+=a[j][k+1]
            c += a[j][0]
    flag = 1
    for y in d:
        if y<x:
            flag = 0
    if flag:
        ans = min(ans,c)

if ans == 10**10:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 68528
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <stdio.h>

int main(void){
  long long h,w;
  std::cin >> h >> w;
  
  if(h==1||w==1) std::cout << "1";
  else std::cout << (h*w+1)/2;
  return 0;
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    long a, b;
    cin >> a >> b;
    int res = 1;
    for (int i = 2; (long)i * i <= a; i++) {
        if (a % i == 0 && b % i == 0) {
            res++;
        }
        while (a % i == 0) a /= i;
        while (b % i == 0) b /= i;
    }
    if (a > 1 && b % a == 0) res++;
    cout << res;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  long long N, M, sum =0;
  cin >> N >> M;
  long long A[M];
  for(int i = 0; i < M; i++) {
    cin >> A[i];
    sum += A[i];
  }
  int ans;
  ans = N - sum;
  if(ans >= 0) cout << ans;
  else cout << -1;
}


Measured memory_bytes: 3752
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
ll dp1[2][15050][2];
ll dp2[15050][2];
int main()
{
	int num, a, b;
	scanf("%d%d%d", &num, &a, &b);
	if (a > b)swap(a, b);
	for (int k = 0; k < 2; k++)
	{
		dp1[k][0][k] = 1;
		for (int i = 0; i < num; i++)
		{
			for (int j = a; i + j <= num; j++)dp1[k][i + j][0] = (dp1[k][i + j][0] + dp1[k][i][1]) % mod;;
			dp1[k][i + 1][1] = (dp1[k][i + 1][1] + dp1[k][i][0] + dp1[k][i][1]) % mod;
		}
	}
	//for (int k = 0; k < 2; k++)for (int i = 0; i <= num; i++)for (int j = 0; j < 2; j++)printf("%d %d %d  %lld\n", k, i, j, dp1[k][i][j]);
	dp2[0][0] = dp2[0][1] = 1;
	for (int i = 0; i < num; i++)
	{
		for (int j = 1; j < a; j++)
		{
			dp2[i + j][0] = (dp2[i + j][0] + dp2[i][1]) % mod;
		}
		for (int j = 1; i + j <= num && j <= b - 1; j++)
		{
			int z1 = 0;
			if (i == 0)z1 = 1;
			if (i + j != num)
			{
				dp2[i + j][1] = (dp2[i + j][1] + dp2[i][0] * dp1[z1][j][1]) % mod;
			}
			else
			{
				dp2[i + j][1] = (dp2[i + j][1] + dp2[i][0] * (dp1[z1][j][0] + dp1[z1][j][1])) % mod;
			}
		}
	//	printf("%lld %lld\n", dp2[i + 1][0], dp2[i + 1][1]);
	}
	ll s = 1;
	for (int i = 0; i < num; i++)s = s * 2 % mod;
	printf("%lld\n", (s + mod + mod - dp2[num][0] - dp2[num][1]) % mod);
}

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

int main()
{
    int n, q, x, cnt = 0;
    int A[100000];

    cin >> n;

    for (int i = 0; i != n; ++i)
    {
        cin >> A[i];
    }

    cin >> q;

    for (int i = 0; i != q; ++i)
    {
        cin >> x;

        if (*lower_bound(A, A+n, x) == x)
        {
            ++cnt;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int main() {
    int N,M; cin >> N >> M;
    vector<P> graph(M);
    rep(i,M) cin >> graph.at(i).first >> graph.at(i).second;
    int bridge_count = 0;
    //除くedgeでループ
    rep(rm_edge,M) {
        vector<vector<int>> G(N,vector<int>());
        rep(i,M) {
            if(i != rm_edge) {
                int a = graph.at(i).first;
                int b = graph.at(i).second;
                G.at(a-1).push_back(b-1);
                G.at(b-1).push_back(a-1);
            }
        }
        vector<int> dist(N,-1);
        queue<int> que;
        int count = 0;
        for(int v = 0; v < N; v++) {
            if(dist.at(v) != -1) continue;
            dist.at(v) = 0;
            que.push(v);
            while(!que.empty()) {
                int v = que.front(); 
                que.pop();
                for(auto w:G.at(v)) {
                    if(dist.at(w) != -1) continue;
                    que.push(w);
                    dist.at(w) = dist.at(v) + 1;
                }
            }
            count++;
        }
        if(count > 1) bridge_count++;
    }
    cout << bridge_count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, m;
    while(cin >> n >> m, n|m){
        long double ans = 1e10;
        for (int i = 0; i <= n; ++i) {
            ans = min(ans, fabs((long double)m-hypot(i, n-i)));
        }
        printf("%.10Lf\n", ans);
    }
    return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main (void){
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double h_rad = (H*2*M_PI + M*2*M_PI / 60.0) / 12.0;
    double m_rad = M*2*M_PI / 60.0;
    
    printf("%.10f", sqrt(A*A + B*B - 2 * A * B * cos(h_rad - m_rad)));

}


Measured memory_bytes: 4212
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<iomanip>
#include<fstream>
#include<ctime>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 100005;

LL wyn, r;
int res[N], a[N], b[N], c[N], i, ind, n;

int main() {
scanf("%d", &n);
for (i=0;i<n;i++) scanf("%d", &a[i]);
for (i=0;i<n;i++) scanf("%d", &b[i]);
for (i=0;i<n;i++) scanf("%d", &c[i]);
sort(a, a + n);
sort(b, b + n);
sort(c, c + n);

ind = -1;
for (i=0;i<n;i++) {
	while (ind + 1 < n && a[ind + 1] < b[i]) ind++;
	res[i] = ind + 1;
}
ind = -1;
r = 0;
wyn = 0;
for (i=0;i<n;i++) {
	while (ind + 1 < n && b[ind + 1] < c[i]) {
		ind++;
		r += res[ind];
	}
	wyn = wyn + r;
}
cout << wyn << endl;

return 0;
}


Measured memory_bytes: 1792
let () =
  let soc = fun n -> Char.escaped (char_of_int (97+n)) in
  let rec check n m l = if n <= m then (n-1, l-1) else check (n-m) (m*26) (l+1) in
  let rec make (n, k) =
    if k = 0 && n = 0 then soc n
    else if k = 0 then soc n
    else
      let y = int_of_float (26. ** (float_of_int k)) in
      let x, m = n / y, n mod y in soc x ^ make (m, (k-1)) in
  Scanf.scanf "%d\n" @@ fun n -> Printf.printf "%s\n" (make (check n 26 1))

Measured memory_bytes: 4152
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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 end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    double ans = 0;
    in >> N;
    vector<double> v(N);
    
    REP(i,N){
        in >> v[i];
    }

    SORT(v);


    REP(i,N-2){
        v[i+1] = ( v[i] + v[i+1] ) / 2;
    }

    out << ( v[N-1] + v[N-2] ) / 2 << endl;

}

Measured memory_bytes: 256
/*
LCS 最长公共子序列，输出方案 
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 3005
int dp[MAXN][MAXN];
char s[MAXN], t[MAXN];
void print(int i, int j){
    if(i == 0 || j == 0) return;
    if(s[i] == t[j]){
        print(i-1, j-1);
        putchar(s[i]);
    }
    else{
        if(dp[i-1][j] >= dp[i][j-1])
            print(i-1, j);
        else
            print(i, j-1);
    }
}
int main(){
    scanf("%s", s+1);
    scanf("%s", t+1);
    int sl = strlen(s+1);
    int tl = strlen(t+1);
    for(int i = 1; i <= sl; i++)
        for(int j = 1; j <= tl; j++)
            if(s[i] == t[j])
                dp[i][j] = dp[i-1][j-1]+1;
            else
                dp[i][j] = std::max(dp[i][j-1], dp[i-1][j]);
    print(sl, tl);
    return 0;
}


Measured memory_bytes: 35456
H, W = [int(_) for _ in input().split()]
N = int(input())
A = [int(_) for _ in input().split()]

rows = [[0] * W for i in range(H)]

x, y, d = 0, 0, 1
for c, a in enumerate(A):
    for i in range(a):
        rows[y][x] = c + 1
        x += d
        if x < 0 or x >= W:
            d = -d
            x += d
            y += 1

for row in rows:
    print(*row)

Measured memory_bytes: 3920
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string x,xx;
    int flag = 1;
    cin >> x;
    char a = x[x.size()-1];
    for(int i=0;i<2;i++){
        cin >> xx;
        if(a != xx[0]) flag = 0;
        a = xx[xx.size()-1];
    }
    if(flag) cout<<"YES";
    else cout<<"NO";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(x) scanf("%lld",&x)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll d,s,t;
  cin>>d>>t>>s;
  ll ds = t*s;
  if(d<=ds) cout<<"Yes";
  else cout<<"No";
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;

constexpr int N = 3e5+5;

int h,w,m;
int x,y;
map<P,bool>mp;
vector<int>cnt1,cnt2;
int row[N],col[N];
int maxr,maxc;

int main()
{
   IOS;
   cin >> h >> w >> m;
   rep(i,1,m)
   {
       cin >> x >> y;
       mp[{x,y}] = true;
       row[x]++;
       col[y]++;
       maxr = max(maxr,row[x]);
       maxc = max(maxc,col[y]);
   }
   rep(i,1,h)
   {
       if(row[i] == maxr)cnt1.pb(i);
   }
   rep(i,1,w)
   {
       if(col[i] == maxc)cnt2.pb(i);
   }
   for(int i=0;i<cnt1.size();++i)
   {
       for(int j=0;j<cnt2.size();++j)
       {
           if(!mp[{cnt1[i],cnt2[j]}])
           {
               cout << maxr+maxc;
               return 0;
           }
       }
   }
   cout << maxr+maxc-1;
}


Measured memory_bytes: 28456
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	int n, m;
	cin >> n >> m;
	int ans = 0;
	pair<int, int>a[55];
	 bool f[55][55] = {};
	for (int i = 0; i < m; i++) {
		cin >> a[i].first >> a[i].second;
		f[a[i].first][a[i].second] = 1;
		f[a[i].second][a[i].first] = 1;
	}
	for (int i = 0; i < m; i++) {
		int r = 0;
		f[a[i].first][a[i].second] = 0;
		f[a[i].second][a[i].first] = 0;
	//	cout << a[i].first << a[i].second << endl;
		vector<int>p;
		p.push_back(1);
		int x = 1;
		bool g[55] = {};
		g[1] = 1;
		r++;
		while (p.size()) {
			for (int j = 0; j < 52; j++) {
				//if (g[j])continue;
				if (f[x][j]) {
				//	cout << j <<endl;;
					if (!g[j]) { g[j] = 1; r++; p.push_back(j); }
				}
			}
			x = p.back(); p.pop_back(); g[x] = 1;
//			cout << x <<i<< endl;;
		}
	//	cout << r << endl;
		if (r < n)ans++;
		f[a[i].first][a[i].second] = 1;
		f[a[i].second][a[i].first] = 1;

	}
	cout << ans << endl;


	

		return 0;

}




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

using namespace std;

#define int long long
#define pii pair<int,int>
#define fi first
#define se second

const int N = 1e5+1, mod = 1e9+7;

int n,m,s,t;

vector<pii> g[N];
int dist[2][N], num[2][N];

void dijkstra(int mode, int x){
	fill(dist[mode], dist[mode]+N, (int)1e18);
	
	priority_queue<pii,vector<pii>,greater<pii>> pq;
	pq.push({0,x});
	dist[mode][x] = 0;
	num[mode][x] = 1;

	while(!pq.empty()){
		int d,u;
		tie(d,u) = pq.top();
		pq.pop();
		if(d==dist[mode][u]){
			for(auto nxt:g[u]){
				int v,w;
				tie(v,w) = nxt;
				if(dist[mode][v] >= dist[mode][u] + w){
					if(dist[mode][v]==dist[mode][u] + w){
						(num[mode][v] += num[mode][u]) %= mod;	
					}else{
						dist[mode][v] = dist[mode][u] + w;
						num[mode][v] = num[mode][u];
						pq.push({dist[mode][v],v});
					}
				}
			}
		}
	}
}

vector<pair<pii,int>> edge;

int sqr(int x){
	return (x%mod)*(x%mod)%mod;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> m >> s >> t;	
	for(int i=0;i<m;++i){
		int u,v,c;
		cin >> u >> v >> c;
		edge.push_back({{u,v},c});
		g[u].push_back({v,c}), g[v].push_back({u,c});
	}
	dijkstra(0,s), dijkstra(1,t);
	int fin = dist[0][t], ans = num[0][t]*num[1][s]%mod;
	
	for(int i=1;i<=n;++i){
		if(fin%2==0 && dist[0][i]==fin/2 && dist[1][i]==fin/2){
			ans = (ans - sqr(num[0][i]*num[1][i]) + mod*mod)%mod;
		}
	}
	
	for(auto e:edge){
		if(dist[0][e.fi.fi] < fin/2 && dist[1][e.fi.se] < fin/2 && dist[0][e.fi.fi] + dist[1][e.fi.se] + e.se == fin){
			ans = (ans - sqr(num[0][e.fi.fi]*num[1][e.fi.se]) + mod*mod)%mod;
		}
		if(dist[0][e.fi.se] < fin/2 && dist[1][e.fi.fi] < fin/2 && dist[0][e.fi.se] + dist[1][e.fi.fi] + e.se == fin){
			ans = (ans - sqr(num[0][e.fi.se]*num[1][e.fi.fi]) + mod*mod)%mod;
		}
	}	
	cout << ans;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> b.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> c.at(i);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll sum = 0;
    for (ll i : b) {
        auto index_a = lower_bound(a.begin(), a.end(), i);
        auto index_c = upper_bound(c.begin(), c.end(), i);
        ll dist_a = n - distance(index_a, a.end());
        ll dist_c = distance(index_c, c.end());
        sum += dist_a*dist_c;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 2560
/*													   *********************
													   	     H. GRID 1	
													   *********************                   Atharva Tripathi                                 */
													   
import java.util.*;
import java.io.*;
public class Main
{
	static int mod=(int)(1e9+7);
	public static class pair
	{
		int x;
		int y;
		public pair(int x,int y)
		{
			this.x=x;
			this.y=y;
		}
	}
	
	public static void main(String args[]) throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String inp[]=br.readLine().split(" ");
		int n=Integer.parseInt(inp[0]),m=Integer.parseInt(inp[1]);
		
		
		int ans[][]=new int[n][m];
		char dp[][]=new char[n][];
		for(int i=0;i<n;i++)
		{
			dp[i]=new char[m];
			dp[i]=br.readLine().toCharArray();
		}
		
		
		for(int i=0;i<m;i++)
		{
			if(dp[0][i]=='#')
				break;
			ans[0][i]=1;
		}
		
		
		for(int i=0;i<n;i++)
		{
			if(dp[i][0]=='#')
				break;
			ans[i][0]=1;
		}
		
		
		for(int i=1;i<n;i++)
		{
			for(int j=1;j<m;j++)
			{
				if(dp[i][j]!='#')
				{
					ans[i][j]=(ans[i-1][j]+ans[i][j-1])%mod;
				}
			}
		}
		System.out.println(ans[n-1][m-1]);
		
		
	}
}

Measured memory_bytes: 33720
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=100001;
ll gcd(ll a,ll b){
  if(b==(ll)0)return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){
  if(a==(ll)0 or b==(ll)0)return (ll)0;
  return ( (b/gcd(a,b) )*a);
}
int main(){
  int n;
  cin>>n;
  ll res;
  for(int i=0;i<n;i++){
    ll tmp;
    cin>>tmp;
    
    if(i!=0)res=lcm(res,tmp);
    else res=tmp;
  }
  cout<<res<<endl;

  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

	public static void main(String[] args){
	
		Scanner sc = new Scanner(System.in);

		int R = sc.nextInt();

		if(R < 1200) System.out.println("ABC");
		else if(R < 2800) System.out.println("ARC");
		else System.out.println("AGC");
	}
}

Measured memory_bytes: 21332